Google Maps API alternative

As Google is now charging a lot more for using the Google maps API, has anyone found a good alternative and is willing to share a desktop example of how to use it?
Although it’s not hard to get a Google API, they do now require payment. @Paul Lefebvre : Maybe you could help us out here?
The current implementation gives a warning and no longer shows maps for free.

1 Like

For my windows app, I am using Leaflet https://leafletjs.com which is a Javascript which works with OpenStreet Map. You should be able to use the HTMLViewer to show the map.

1 Like

Hi Boundewijn,

LeafLeft works great for me. I’m just using it for the basic of showing the coordinates spot in the map, but the API provides much more advanced stuff that you can implement too.

Javier

@Edwin Lau & @Javier Menéndez : thanks for the quick reply, but at first glance this does not offer showing a map based on address input, but based on GPS coordinates only. Can anyone share an example of an alternative using a street address as an input?

For me, I’m gonna use the new @Christian Schmitz MBS plugin using Apple MapKit. Changing from Google API take me a few minutes for a very nice result.

@Valdemar De SOUSA Thanks, I’m a big fan of MBS and did not know Christian has an alternative: I’ll have a look.

I am using Christian MBS’s Apple MapKit Monkeybread Xojo plugin - MapKit for the Mac which works great if you are only deploying for the Mac. It would not however work for Windows.

Leaflet on it’s own would require coordinates to show the map so since they are using OpenStreetMap, what I did to convert address to Coordinates is to make a call to their OpenStreetMap Search server. In the below example, I search for the Empire State building to get back a Json File which I would search for the Lat and Long values to use with Leaflet.

https://nominatim.openstreetmap.org/search?format=json&q=“Empire State Building”&addressdetails=0

you also have openstreemap that is completely free.

@Javier Menéndez - are you willing to share just a small peace of code, just to kick off quickly. ?

Hey @Joost Rongen!

What do you prefer more? A snippet of code or a video tutorial / blog post about how to use it? :slight_smile:

Javier

I guess you have a lot of work to do Javier, so I chose what is appropriate for you. it would be a great service for many of us.

Javier, could you please show us, how to get a map as a Picture into a Desktop App (in a Canvas) without using HTMLViewer? Would be nice, thanks.

(I’ll take an eye on the Picture option, meanwhile for the HTMLViewer based version…)

I’ll try summarize what I do (sorry in advance for not add explanations to the snippets of code):

1. I have an HTML Subclass with a kHTMLSourceCode constant whose content is (easy to modify to adequate to other purposes or delete something). You should substitute the “TOKENTOKENTOKEN” string for your own:

[code]

[/code]

2. Then, the subclass has the method (among others) LoadMap( longitude as String, latitude as String ) with the following code:

[code]coordinates = new pair(0,0)

Dim sourceHTML As String = kHTMLSourceCode.ReplaceAll("##LONG##", longitude)
sourceHTML = sourceHTML.ReplaceAll("##LAT##", latitude)

Dim tHeight As Integer = Me.Height
Dim tWidth As Integer = Me.Width

sourceHTML = sourceHTML.Replace("##H##", tHeight.ToText)
sourceHTML = sourceHTML.Replace("##W##", tWidth.ToText)

Me.LoadPage(sourceHTML, SpecialFolder.Temporary.Child(“Map”) )

coordinates = new pair(longitude, latitude)[/code]

Forget about the Coordinates property (I use it for other things).

Javier

Thanks a lot @Javier Menéndez - Got me a token, put this sample together and have a flying start. And as you know, a good start is half the work. :slight_smile:

I switched the Eddie’s Electronics desktop demo app to use MapBox instead of Google Maps for 2018r4:

Examples/Sample Applications/EddiesElectronics/Desktop

CustomerDetailsWindow.RequestMap sends the request to a LocationSocket to get a geocode location for the address. The LocationSocket.PageReceived event sends a request to MapSocket to get the map as a Picture. The MapSocket.PageReceived event converts the returned binary data to a Picture which is displayed by MapCanvas.Paint.

Our whole business with it’s applications are leaflet and openstreetmaps based.

We wrote our own leaflet controls, together with the apis of graphhopper.com. Additional, we use Mapbox Studio to design our maps the way we like.

So: I can highly recommend this toolset: leaflet.js, graphhopper, mapbox studio (free) and own written controls.

I’ll attach some screenshots of our apps to show the possibilities.
https://github.com/VanDerLars/upload_stuff/blob/master/Bildschirmfoto%202018-02-07%20um%2011.34.13%20(2).png
https://github.com/VanDerLars/upload_stuff/blob/master/Karte.png

See my blog post:

https://www.mbsplugins.de/archive/2019-01-08/MapKit_Framework_for_Xojo

You can show map, get directions and find local items on the map.

Thanks Paul, didn’t saw this. Looks like the MapPicture is in low resolution. Any chance to get it in high resolution e.g. for Retina Displays?

How about Here?
It’s free for up to 250k transactions per month

It provides (reverse)geocoding, address-autocompletion etc.