2013-07-12 52 views
0

如何從Json文件過濾gmap標記?過濾gmap標記,怎麼樣?

 
$(function() { 

       demo.add(function() { 
        $('#map_canvas').gmap({'disableDefaultUI':false, 'callback': function() { 

         var self = this; 
         $.getJSON('demo.asp', function (data) { 
          $.each(data.markers, function(i, marker) { 
           self.addMarker({ 'position': new google.maps.LatLng(marker.latitude, marker.longitude), 'bounds':true }).click(function() { 
            self.openInfoWindow({ 'content': marker.content }, this); 
           }); 
          }); 
         }); 
        }}); 
       }).load(); 
      }); 

回答

0
$(function() { 

       demo.add(function() { 
        $('#map_canvas').gmap({'disableDefaultUI':false, 'callback': function() { 

         var self = this; 
         $.getJSON('demo.asp', function (data) { 
          $.each(data.markers, function(i, marker) { 
          if(marker!="filtered data"){ 

           self.addMarker({ 'position': new google.maps.LatLng(marker.latitude, marker.longitude), 'bounds':true }).click(function() { 
            self.openInfoWindow({ 'content': marker.content }, this); 
          } 
           }); 
          }); 
         }); 
        }}); 
       }).load(); 
      }); 

你可以有過濾,或將其過濾上獲取JSON數據的邏輯。

+0

謝謝探礦者! –

+0

如果它幫助您考慮點擊您可以向上或向下投票的複選框。 – prospector