2013-07-12 3 views
0

Как фильтровать gmap-маркеры из Json-файла?Фильтрация маркеров 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

Thank's Prospector! –

+0

, если это поможет вам подумать о том, чтобы установить флажок, в котором вы можете проголосовать вверх или вниз. – prospector

Смежные вопросы