0

Phonegap 애플리케이션에서 Google지도를 표시하기 위해 Google gmap API를 사용하고 있습니다. gmap이 정상적으로 작동합니다.Gmap이 두 번째 이후에 새로 고침하지 않습니다

그러나 내 요구 사항은 사용자 선택에 따라 마커를 변경하고 처음에는 모든 마커를 표시합니다. 두 번째 이후부터 나는 사용자가 선택한대로 보여줄 필요가있다. 나는

아래는 GMAP 코드 JSON 데이터를 사용하고 있습니다 :

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); 
          } 
       }); 
} 

문제는 전방으로은 "바인딩"메소드가 실행되지 않은 두 번째 통화에서입니다.

답변

0

두 번째 이후부터 마커를 지우고 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); 
       } 
관련 문제