Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery-ui-map load json and update markers
    primarykey
    data
    text
    <p>I've searched all over the web and SO, but I couldn't figure this out.</p> <p>Here's the problem:</p> <p>I'm using the below demo from jquery-ui-map site to load a JSON file:</p> <p><a href="http://jquery-ui-map.googlecode.com/svn/trunk/demos/jquery-google-maps-json.html" rel="nofollow">http://jquery-ui-map.googlecode.com/svn/trunk/demos/jquery-google-maps-json.html</a></p> <p>It works fine to load my markers, but I need to refresh its content every 30 seconds and grab new markers.</p> <p>At first I thought I would just call the function again, but that left the markers there. After some research I found out I needed to clear the markers (not so easy on V3, but I was able to to do) but the issue is that I can't get the markers to show again.</p> <p>If I use the destroy function, then I'm able to reload new markers and remove the old ones, but that causes the map to blink. When I try to clear markers then no new markers are shown.</p> <p>Any help is greatly appreciated.</p> <p>Below is my code:</p> <pre><code>&lt;script type="text/javascript"&gt; function mapTest() { $('#map_canvas').gmap('destroy'); //clearMap(); demo.add(function() { $('#map_canvas').gmap({'disableDefaultUI':true, 'callback': function() { var self = this; $.getJSON( 'json/demo.json?'+ new Date().getTime(), 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(); } function clearMap(){ $('#map_canvas').gmap('clear', 'markers'); } mapTest(); setInterval(mapTest, 30000 ); &lt;/script&gt; </code></pre> <p>Cheers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload