Geocode is right. It seems as if you try to plot a new marker on the map at every step (and without removing the old one). Why not try to plot one marker and update it's latlng instead?
I don't see anything wrong with that code off the bat (syntactically), so it's possible you're at a too high zoomlevel to notice the new markers. The increment is about 1 meter, which means you won't see anything move till at least zoomlevel 10ish. Or maybe some error occurs and the script doesn't repeat. This is why we'd like to see a link. On 9 jan, 15:18, Troels <[email protected]> wrote: > Hey > > I want to demonstrate a moving bus on a map. I have a function called > plotPoints() which plots points with markers and so on. I the top of > my script i set a interval for setting a new plot, and some code does > increase the position of the marker. It wouldn't seem to work. Its > only plotting the first marker. > > Here is the code: > > <script type="text/javascript"> > //<![CDATA[ > > var map; > var bounds; > function load() { > if (GBrowserIsCompatible()) { > map = new GMap2(document.getElementById("map")); > map.addControl(new GLargeMapControl()); > map.addControl(new GMapTypeControl()); > map.setCenter(new GLatLng(56.1662,10.1937), 11); > map.setMapType(G_NORMAL_MAP); > map.enableScrollWheelZoom(); > map.disableDoubleClickZoom(); > setInterval(plotPoints(), 1000 ); > > } > } > > var gmarkers = []; > var htmls = []; > > // handle clicks from the listing: > function click(i){ > gmarkers[i].openInfoWindowHtml(htmls[i]); > } > > // set up a new marker > function addMarker(lat, lon, html, busnr){ > > var icon = new GIcon(busnr); > icon.image = "style/icons/"+ busnr +"icon.png"; > icon.iconSize = new GSize(25, 50); > icon.iconAnchor = new GPoint(5, 50); > icon.infoWindowAnchor = new GPoint(5, 50); > var marker = new GMarker(new GLatLng(lat, lon), icon); > > GEvent.addListener(marker, "click", function() { > // Viser viduet med information når > der trykkes. > marker.openInfoWindowHtml(html); > // Opretter nyt center for mappet. > map.setCenter(new GLatLng(lat,lon), > 16); > } > ); > > gmarkers.push(marker); > htmls.push(html); > return marker; > } > var plus = 0; > function plotPoints(){ > var marker; > > plus=plus+0.0001; > var la = 56.1844496120765+plus; > var lo = 10.19030749797821+plus; > //update('hent') > var html = formatHtml("12","15:49:43"); > marker = addMarker(la,lo, html, "12"); > map.addOverlay(marker); > > } > > function formatHtml(busnr, time) { > return '<h1>Bus Nummer: ' + busnr + '</h1><br > /><b>Sidste > opdatering:</b> ' + time + '<br />'; > } > > //]]> > > I'll hope you guys can help me out here. Thx --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
