Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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
Jquery Gmap不会从第二次开始刷新_Jquery_Google Maps_Cordova_Jquery Mobile_Google Maps Markers - Fatal编程技术网

Jquery Gmap不会从第二次开始刷新

Jquery Gmap不会从第二次开始刷新,jquery,google-maps,cordova,jquery-mobile,google-maps-markers,Jquery,Google Maps,Cordova,Jquery Mobile,Google Maps Markers,我正在使用GoogleGMAPAPI在我的Phonegap应用程序中显示Google地图。gmap运行良好 但是,我的要求是根据用户选择更改标记,首先我显示所有标记。从第二次开始,我需要显示为用户选择。我使用的是Json数据 以下是Gmap代码: function showMap(data) { $('#map_canvas').gmap( { 'center' : initialLocation,

我正在使用GoogleGMAPAPI在我的Phonegap应用程序中显示Google地图。gmap运行良好

但是,我的要求是根据用户选择更改标记,首先我显示所有标记。从第二次开始,我需要显示为用户选择。我使用的是Json数据

以下是Gmap代码:

function showMap(data) {
    $('#map_canvas').gmap(
                        { 'center' : initialLocation,
                          'zoom' : 12,
                          'mapTypeControl' : false,
                          'navigationControl' : false,
                          'streetViewControl' : false
                        })
                        .bind('init', function(evt, map) {
                            if (data.Response.ShopListInfo instanceof Array) {
                                 $.each( data.Response.ShopListInfo, function(i, marker) {
                                              latitude = marker.Latitude;
                                              longitude = marker.Longitude; 
                                              displayMarkers(latitude, longitude, marker);
                                 });
                            }else{
                                latitude = data.Response.ShopListInfo.Latitude;
                                longitude = data.Response.ShopListInfo.Longitude; 
                                displayMarkers(latitude, longitude, data.Response.ShopListInfo);
                            }
                }); 
}

问题是从第二次调用开始,“bind”方法就没有执行。

我们只需要从第二次调用开始清除标记,然后单独调用addMarkers方法,如下所示

$('#map_canvas').gmap('clear', 'markers');
                if (data.Response.ShopListInfo instanceof Array) {
                    $.each( data.Response.ShopListInfo, function(i, marker) {
                          latitude = marker.Latitude;
                             longitude = marker.Longitude; 
                             displayMarkers(latitude, longitude, marker);
                    });
                }else{
                    latitude = data.Response.ShopListInfo.Latitude;
                    longitude = data.Response.ShopListInfo.Longitude; 
                    displayMarkers(latitude, longitude, data.Response.ShopListInfo);
                }