ThinkGeo.com    |     Documentation    |     Premium Support

MapTools to center on me

Hello ThinkGeo.

I am looking for a feature that is extremely common and useful for Mobile bit isn’t for say Desktop maps.

On the Google Map on a Pixel phone down in the right-hand corner is a little blue circle that if you tap on it the map will center on the Devices current location. A zoom to me feature.

I have seen via the IMapTool interface you have the ZoomMapTool and I am wondering if there is a ZoomToMeTool?

If there isn’t then I beleive it isn’t too hard to implement the logic myself and then my next question is how would I implement a fixed button that appears in the bottom right hand corner of the map?

I think what I have asked above is simple to understand but if not happy to clarify.

Regards
Chris …

Hi Chris,

We do show this feature in the Maui HowDoI, you can see it right after launch it

Just click the button on the bottom right:

and you can see the following message popping up if it’s running the first time

Give it the right permission and it brings you to the current spot with a breathing GPS point in the center.

And just FYI, we do show this feature in our Desktop HowDoI as well :).

Thanks,
Ben

Ben,

Thanks for such a quick response.

To preserve my dignity, I shall assume that was a recent update to your sample repository, possibly just this week, which is why I never saw it. :slight_smile:

To defnd myselft a little more … I was looking for a turn-switch implementation much like your zoom map tool.
For example, on the GMaps in Xamarin Forms it was simply MapView.MyLocationEnabled = True;
:slight_smile:

I do have a question about the sample code?
The GpsMarker() when setting the IsVisible property does need an overlay refresh?

I note that when you first set the IsVisible there is no refresh but on the Position there is.
The IsVisible doesn’t require an overlay refresh or do you hope that the 20 second timer will eventually trigger an overlay refresh due to the Position being updated and the marker appear?

Thanks for the excellent help.
Regards
Chris …

Hi Chris,

The GPS sample first landed on the dev branch last summer and was merged into master later. There were a few tweaks since then, which could explain why it didn’t show up on your side earlier especially if you are on the master branch.

We did want to make it as simple as one-line toggle (such as MapView.MyLocationEnabled = true;), the challenge is there are quite a few knobs people want to customize (icon, accuracy ring, follow-mode, refresh cadence, etc.), so we kept it explicit for now. A simpler API is still on the table.

That’s a great question about GpsMarker.IsVisible and refresh :+1:

  1. Pure visibility toggle (no viewport change)
    If you only set IsVisible = true/false and nothing else changes, you don’t need to refresh—the marker is a control and its visibility updates immediately.

  2. Toggled while the map moved (pan/zoom/rotate) while hidden
    If you hide the marker, then the user pans/zooms, and later you set IsVisible = true again, you should force a refresh of the overlay. Otherwise the marker may briefly appear at its last screen transform and only snap to the correct spot on the next redraw (e.g., when the position timer ticks or the user interacts again).

  3. Position updates
    When the marker’s geographic position changes, we always refresh the overlay so the control reprojects/repositions correctly in the current viewport. That’s why you see an explicit refresh on Position updates.

So in a word, always refresh the overlay when a marker’s position got updated, or the marker becomes visible. Also updating the MapView extent (such as MapView.CenterAtAsync(gps)) will refresh all the internal overlays (including the markerOverlay) as well, that’s why we didn’t specifically refresh the makerOverlay in the code.

I hope that makes sense, let me know if you have any questions.

Thanks,
Ben