How do you add pins and move the map region in MAUI Maps?
Short answer
Add Pin objects to Map.Pins with a Location, Label, and Address, and call MoveToRegion with a MapSpan centered on a location and radius. You can handle pin taps via the InfoWindowClicked/MarkerClicked events.
Advertisement
AModel answer
Add Pin objects to Map.Pins with a Location, Label, and Address, and call MoveToRegion with a MapSpan centered on a location and radius. You can handle pin taps via the InfoWindowClicked/MarkerClicked events.
map.Pins.Add(new Pin { Label = "HQ",
Location = new Location(37.79, -122.40) });
map.MoveToRegion(MapSpan.FromCenterAndRadius(
new Location(37.79, -122.40), Distance.FromKilometers(2)));Real-world example
A delivery app drops a pin at the destination and centers the map on it with a 2km view.
Likely follow-ups
- What is a MapSpan? | How do you handle a pin tap?
Related topics