Adding/deleting Markers, but the changes don't appear on the map

44 views
Skip to first unread message

John

unread,
May 11, 2013, 1:42:08 PM5/11/13
to route-...@googlegroups.com
I have an iOS app using route-me to display a static map and place markers on it. The markers are created during the viewWillAppear method of the viewController. This works perfectly; the map and markers appear correctly; zooming and panning work.

However, if I add or delete markers, the added markers do not appear nor do the deleted markers disappear. I have tried using the [RMMarkerManager removeMarkers] method, followed by adding back into the markerManager the markers I want displayed on the app. this has no affect; the original markers remain.

After updating the markerManager with a new set of markers, I can iterate through viewMap.contents.overlay.sublayers and see a sublayer for each marker that I want to display. That makes me think that the problem is that the mapView is not updating correctly, since those sublayers never are displayed.

Any idea why the markers do not display correctly?

I realize this is a very simple - and maybe inadequate - explanation of the problem. I can supply code and more explanation, but I'm hoping there is some simple thing I've stupidly overlooked. Thanks for any and all help.

John

Stephan Hennion

unread,
May 13, 2013, 2:03:01 PM5/13/13
to route-...@googlegroups.com
How are you referencing the markerManager? As in, do you create RMMarkerManager *myManager and pull in the currentMapView's manager, or do you directly access currentMapView.markerManager?

I've had some oddities before with my markers, for example, not being able you marker methods after initialization unless the marker was already uploaded into the markerManager (which makes sense).

Maybe trying "bumping" the map a bit with some methods to zoom in or out real quick, or move it ever so slightly as that might force a refresh.
--
You received this message because you are subscribed to the Google Groups "route-me" group.
To unsubscribe from this group and stop receiving emails from it, send an email to route-me-map...@googlegroups.com.
To post to this group, send email to route-...@googlegroups.com.
Visit this group at http://groups.google.com/group/route-me-map?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


John

unread,
May 13, 2013, 2:45:25 PM5/13/13
to route-...@googlegroups.com
Thanks for the response - it came in at almost exactly the time I discovered the solution (even though I'm still unclear on the "why."). Turns out to not be a view update problem.

On viewWillLoad I call an method that creates an array of markers, which I pass to the markerManager. When the user makes a change that causes a change in what markers are to be displayed, I call the same method. It turns out that creating the marker array again was causing the problem. Moving the marker array to an instance variable, doing the alloc/init in the class's init method, and then updating the marker array rather than creating it anew with an alloc/init solved the problem.

Honestly, I'm not sure why the original approach failed, and when I've got a bit of spare time, I want to dig through the code to really understand what was causing the problem. But for now, it works exactly as I want it to.

John
Reply all
Reply to author
Forward
0 new messages