2013-07-12 51 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