Xamarin Android Google Map - Add marker where user clicks -
in xamarin forms, using custom renderer in android map have implemented using android.gms.maps
want write functionality adds marker in area user clicked on map.
public async void onmapready(googlemap googlemap) { map.mapclick+= handlemapclick; }
in handlemapclick()
function, how use addmarker()
function add marker area user clicked on map?
the googlemap.mapclickeventargs
contains "point" contains lat/long of user' click. create markeroption
, assign point , add map.
googlemap.mapclick += (object sender, googlemap.mapclickeventargs e) => { using (var markeroption = new markeroptions()) { markeroption.setposition(e.point); markeroption.settitle("stackoverflow"); // save "marker" variable returned if need move, delete, update it, etc... var marker = googlemap.addmarker(markeroption); } };
Comments
Post a Comment