Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript setAnimation给出了一个错误_Javascript_Jquery_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript setAnimation给出了一个错误

Javascript setAnimation给出了一个错误,javascript,jquery,google-maps,google-maps-api-3,Javascript,Jquery,Google Maps,Google Maps Api 3,我正在谷歌地图上工作。谷歌地图上有带标记的位置列表 我想要一个功能,当有人在某个特定的位置,该位置的标记会反弹 下面是我正在使用的代码: function google_map(marker_array){ // Setup the different icons and shadows var iconURLPrefix = 'http://maps.google.com/mapfiles/ms/icons/', icons = [

我正在谷歌地图上工作。谷歌地图上有带标记的位置列表

我想要一个功能,当有人在某个特定的位置,该位置的标记会反弹

下面是我正在使用的代码:

function google_map(marker_array){

    // Setup the different icons and shadows

    var iconURLPrefix = 'http://maps.google.com/mapfiles/ms/icons/',

        icons = [
                    iconURLPrefix + 'red-dot.png',
                    iconURLPrefix + 'green-dot.png',
                    iconURLPrefix + 'blue-dot.png',
                    iconURLPrefix + 'orange-dot.png',
                    iconURLPrefix + 'purple-dot.png',
                    iconURLPrefix + 'pink-dot.png',      
                    iconURLPrefix + 'yellow-dot.png'
                ],

        iconsLength = icons.length;

    var map = new google.maps.Map(document.getElementById('map_canvas'), {
                zoom: 10,
                center: new google.maps.LatLng(-37.92, 151.25),
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                mapTypeControl: false,
                streetViewControl: false,
                panControl: false,
                zoomControlOptions: {
                    position: google.maps.ControlPosition.LEFT_BOTTOM
                }
            }),

        infowindow = new google.maps.InfoWindow({
                maxWidth: 160
            });

    var markers = new Array(),

        iconCounter = 0;

    // Add the markers and infowindows to the map
    for (var i = 0; i < marker_array.length; i++) {

        var marker = new google.maps.Marker({
                        position: new google.maps.LatLng(marker_array[i].latitude, marker_array[i].longitude),
                        map: map,
                        icon: icons[iconCounter]
                    });

        markers.push(marker);
        var content_info    =   '<div class="siteNotice" id="content">' +
                                '<h1 id="firstHeading" class="firstHeading"><a href="?page_id=582&store_id='+marker_array[i].id+'">'+marker_array[i].content+'</a></h1>'+
                                '</div>';

        google.maps.event.addListener(marker, 'click', (function(marker, i) {
            return function() {
                infowindow.setContent(marker_array[i].content);
                infowindow.open(map, marker);
            }
        })(marker, i));

        iconCounter++;

        // We only have a limited number of possible icon colors, so we may have to restart the counter
        if(iconCounter >= iconsLength) {
            iconCounter = 0;
        }
    }

    function autoCenter() {
        //  Create a new viewpoint bound
        var bounds = new google.maps.LatLngBounds();
        //  Go through each...
        for (var i = 0; i < markers.length; i++) {  
            bounds.extend(markers[i].position);
        }
        //  Fit these bounds to the map
        map.fitBounds(bounds);
    }

    autoCenter();   

}

google_map(store_details);
上面的代码工作得非常好。但当我尝试设置动画时,它会给我错误:

未捕获类型错误:未定义不是函数

marker.setAnimation;是罪魁祸首,不知何故我无法解决


有没有人可以帮我解决这个问题。

请提供一个示例来说明错误。这是不完整的。没有示例数据或HTML。这远远不是最小的。请提供一个示例来演示错误。也许通过这样做,你会发现问题所在。最终,问题解决了!感谢您宝贵的时间@geocodezip。。
$( "#wpsl-stores" ).on( "mouseenter", "li", function() {
    //console.log($( '.lstore' ).data( "store-id" ));
    letsBounce( $(this).find('.lstore').data("store-id"), "start" );
});

$( "#wpsl-stores" ).on( "mouseleave", "li", function() {    
    letsBounce( $(this).find('.lstore').data("store-id"), "stop" );
});


function letsBounce( storeId, status ) {
    var i, len, animation = "";

    if ( status == "start" ) {
        animation = google.maps.Animation.BOUNCE;       
    } else {
        animation = null;   
    }
    /* Find the correct marker to bounce based on the storeId */
    for ( i = 0, len = store_details.length; i < len; i++ ) {

        if ( store_details[i].id == storeId ) {
            marker = store_details[i];
            marker.setAnimation( animation );//In this line
        }
    }   
}