Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 444

Answer by Liyun Zhang - MSFT for Is Google Maps Sdk programmatically added markers using net8 MAUI free of charge?

$
0
0

First of all, you can check the offcial document about the Android Google Map Marker. And you can add the marker by calling the platform native code.

Give a name to the Map control in the xaml:

<Map x:Name="map" ..../>

And declare the android platform method:

#if ANDROID        public void AddMrker(double x, double y,string title,string snippet)        {            var googlemap = map.Handler.PlatformView as Android.Gms.Maps.GoogleMap;            var markeroption = new Android.Gms.Maps.Model.MarkerOptions();            markeroption.SetIcon(Android.Gms.Maps.Model.BitmapDescriptorFactory.FromResource(Resource.Drawable.dotnet_bot));            markeroption.SetPosition(x, y);            markeroption.SetTitle(title);            markeroption.SetSnippet(snippet);            googlemap.AddMarker(markeroption);        }#endif

You can copy your custom image file into the \Resources\Images\pin.png and set its buid action as MauiImage. And use it:

markeroption.SetIcon(Android.Gms.Maps.Model.BitmapDescriptorFactory                              .FromResource(Resource.Drawable.pin));

In addition, you can check the official document about the Maui Map Pins and this case about custom map pin.


Viewing all articles
Browse latest Browse all 444

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>