- This topic has 10 replies, 4 voices, and was last updated 11 years, 5 months ago by
TorbenKjeldgaard.
-
AuthorPosts
-
TorbenKjeldgaardMemberHi,
I’m having a small issue on my map. When I go to the map it place correctly a new marker (from lat,lng from a list). Each time I go to the mapscreen, the markers set previous is still there… How do I delete all previous markers when entering the mapscreen.
Cheers
TKT
FunciParticipantHi TKT,
Maybe something like in this topic with SetMap(null)?
http://www.genuitec.com/support-genuitec/viewtopic.php?f=8&t=5183&hilit=polyline
TorbenKjeldgaardMemberHi Funci,
thanks for your suggestion.
I’ve been trying to solve it, but I’m not quite sure that’s the problem. The first time I go to the map screen the markers are placed and work just fine. If I navigate around the map (move it) leave the screen and come back – the map is not centered to my location as the first time. Seems like the page are cached or something, but I’ve checked the “No offline support”.
I would like the screen to refresh, each time I enter it.
FunciParticipantYes… I’ve noticed the same thing in my project, but I can set center of the page when coming back from another screens by some parameters…
Maybe you can dynamicly save in some variable centered location of the map before you leave that screen and on returning set center again on that coordinates?
Unknown AuthorParticipantRemember: You’re pushing and poping markers from an array. So, you need to clear the array and reset its length.
Here’s what I use to delete overlays.
function deleteOverlays(){ if (markersArray) { for (i in markersArray){ markersArray[i].setMap(null); } markersArray.length = 0; } }
For more fun with GoogleMaps, check out my app, Proximal, on iTunes:
https://itunes.apple.com/us/app/proximal/id572222453?mt=8-1TC
TorbenKjeldgaardMemberThank you thin chip,
However I’ve been on a vacation, and apparently for to long time, because I can not get my brain to work right :-/
Im adding the markers like this:
// if(parm=='mypos'){ mapoptions = {position:pos, map:gmap, animation:google.maps.Animation.DROP, //BOUNCE, title: itemhead, timeout:300, clickable: true}; var marker = new google.maps.Marker(mapoptions) var infowindow = new google.maps.InfoWindow({ content: itemhead }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(gmap,marker); }); } //
I’ll be very greatfully if you could tell me exactly how the syntax be to remove them, in that case.
Thank you
Torben
Unknown AuthorParticipantI will not write your app for you.
-1TC
TorbenKjeldgaardMemberHi 1thinchip,
fair enough 🙂
I guess I just have to skip long vacations in the future then…
TorbenKjeldgaardMemberOkay Anyone – I can’t get rid of these fuc….ig markers.
I’ve tried the solutions posted here – I’ve read the google API – I still can’t figure it out!
can anyone please help me.
Where do I put the setMap(null)
regards
TKT
support-michaelKeymasterDid you take a look at this example https://developers.google.com/maps/documentation/javascript/examples/marker-remove
Does the marker removal problem only occur when you move to another screen and then return?
TorbenKjeldgaardMemberHi support-wayne,
Yes I’ve looked at this also. But I don’t understand why I can see the markers without using “markers.push(marker)” – that means that the markers is not in an array or?
I’ve been using this example when I started on this project.
https://docs.google.com/document/d/1lAKCcL11tonv8lzxgZXCbBYloNWUkjr0FltJozQ6cR8/editThe problem is that I have a list with different lat & lng, when I click an item on this list, I go to the map screen which shows a pin gfor the position I’ve just clicked. When I go back to the list and click a new item, the previous marker is still there. Eg. if I’ve clicked 12 items on the list, the map will show 12 markers.
I want the map only to show the marker for the item I’ve clicked.
Does this make sense?
Regards
TKT -
AuthorPosts