Example of how to add pins in maps with click in Xamarin.Forms applications. - http://julianocustodio.com/adicione-pontos-no-maps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Android.Gms.Maps; | |
using PinClickDemo; | |
using PinClickDemo.Droid; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Maps; | |
using Xamarin.Forms.Maps.Android; | |
using Xamarin.Forms.Platform.Android; | |
[assembly: ExportRenderer(typeof(ExtendedMap), typeof(ExtendedMapRenderer))] | |
namespace PinClickDemo.Droid | |
{ | |
public class ExtendedMapRenderer : MapRenderer, IOnMapReadyCallback | |
{ | |
private GoogleMap _map; | |
public ExtendedMapRenderer() | |
{ | |
} | |
protected override void OnMapReady(GoogleMap googleMap) | |
{ | |
_map = googleMap; | |
if (_map != null) | |
{ | |
_map.MapClick += googleMap_MapClick; | |
} | |
} | |
protected override void OnElementChanged(ElementChangedEventArgs<Map> e) | |
{ | |
if (_map != null) | |
{ | |
_map.MapClick -= googleMap_MapClick; | |
} | |
base.OnElementChanged(e); | |
if (Control != null) | |
((MapView)Control).GetMapAsync(this); | |
} | |
private void googleMap_MapClick(object sender, GoogleMap.MapClickEventArgs e) | |
{ | |
((ExtendedMap)Element).OnTap(new Position(e.Point.Latitude, e.Point.Longitude)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment