javascript - Google maps - how to add marker without layout refresh -


have problem marker adding.

        var marker = new google.maps.marker({         position: mylatlng,         title:"hello world!"     });      // add marker map, call setmap();     marker.setmap(map); 

https://jsfiddle.net/73ogq84a/

simple example, each seconds put marker, page not reloading, reloading layout , see effect of map reload.

it possible put marker smoothly.

but on page http://www.flightradar24.com/simple_index.php working fine, planes flying , no effect of map reload.

make marker , map global. don't recreate map every time, move marker.

var map, marker, mylatlng;  setinterval(function () {     if (!marker || !marker.setposition) {         marker = new google.maps.marker({             position: mylatlng,             title: "hello world!"         });          // add marker map, call setmap();         marker.setmap(map);     } else {         marker.setposition(mylatlng);     }  }, 5000); 

updated fiddle


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -