0

I am testing a very simple application that get the location from the GPS information and I would like to show it in a map.

I know that it is possible to use the native maps application of android with MAUI, but it makes me to create a develop account in google, get a API-Key and give a credit card because it is a pay service if from the application it is requesting N positions.

I would like to avoid all this process, so i would like if there is some another way to show a location in a map in an MAUI application.

Thanks.

Álvaro García
  • 18,114
  • 30
  • 102
  • 193
  • According to this case about [Getting Current Location in WebView Google maps](https://stackoverflow.com/questions/38869786/get-current-location-in-webview-google-maps), you can use the webview to load the URL of the Google Maps site. – Liyun Zhang - MSFT Mar 06 '23 at 08:07

2 Answers2

1

You need the api key only if you want to use Google Maps inside your application.

You should be able to show a position on the map opening the Google Maps app with your app.

Check this link.

Riccardo Minato
  • 520
  • 2
  • 11
  • Thanks, this work. But would it be possible to show the map in a user control to don't need to open the default application? In this way I would have to avoid to have to back to the application. – Álvaro García Mar 01 '23 at 16:50
  • Yes, the way to do this involves setting up Google maps. Otherwise find an alternative map control to use – Jason Mar 01 '23 at 19:42
  • I guess you can't skip a setup procedure using a complex third part control as a Map. Maybe OpenStreetMap is a viable option, but I didn't found any library to integrate it in MAUI. You could have a chance with [Blazor Hybrid](https://learn.microsoft.com/en-us/aspnet/core/blazor/hybrid/) – Riccardo Minato Mar 02 '23 at 13:34
  • @ÁlvaroGarcía you can do stuff like this: https://www.google.com/maps/place/43%C2%B025'22.3%22N+34%C2%B013'56.1%22E – H.A.H. Mar 02 '23 at 17:48
0

As alternative:

https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/webview?view=net-maui-7.0&pivots=devices-android

(Some people may disagree, because the Map class answer is the correct one, and the one I use, but it is good to know other ways)

H.A.H.
  • 2,104
  • 1
  • 8
  • 21
  • I guess the option it is to use the Map class, but to can use it it is needed to register the API of google and it is not free. So the WebView control it seems a possible solution. – Álvaro García Mar 02 '23 at 18:16
  • @ÁlvaroGarcía Do you make a difference between this: https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/map?view=net-maui-7.0 , And this : https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/appmodel/maps?view=net-maui-7.0&tabs=android . One is a Control, the other is just launching the map application. – H.A.H. Mar 02 '23 at 18:27
  • Then I guess I misunderstood when you told about Map class. But yes, I know the difference between the Map control, that needs the API KEY from goolge, and only just launch the default maps application of the system. This second option it is a bit annoyed because make the users to have to back to the application, so WebView it can be a bit more interested in my case. – Álvaro García Mar 02 '23 at 18:33