Tester for map position helper (Php class)

This helper class can parse urls of a map services Google maps, Openstreetmap, Yandex and many others. It fetches the position longitude and latitude from an url.

It generates urls with the same position with other map services.

Try it yourself!

  1. Open Google maps or Flightradar 24 or Open street map or Windy or Yandex map,
  2. Zoom in, go to any position and then
  3. Copy the url and paste it below.

Output

URL: https://www.google.com.br/maps/@-22.7405789,-47.3313609,20.25z

Get the position

$oMaphelper->getPos("https://www.google.com.br/maps/@-22.7405789,-47.3313609,20.25z")
Array ( [source] => https://www.google.com.br/maps/@-22.7405789,-47.3313609,20.25z [provider] => google [lat] => -22.7405789 [lon] => -47.3313609 [zoom] => 20.25 )

Urls that point to the same position

$oMaphelper->getUrls();
Array ( [google] => https://www.google.com/maps/@-22.7405789,-47.3313609,20.25z [map1eu] => [mapillary] => [fligthtradar24] => [osm] => [wikimapia] => [windy] => [yandex] => )

Fix position values

What you see in the resultset above is: we did not get links to all providers.

BUT: There is a healing function that creates compatible values. The key _warnings contains info messages, what was fixed.
$oMaphelper->fixPosition();
Array ( [source] => https://www.google.com.br/maps/@-22.7405789,-47.3313609,20.25z [provider] => google [lat] => -22.7405789 [lon] => -47.3313609 [zoom] => 17 [_warnings] => Array ( [0] => zoom level is not integer. [1] => zoom level 20.25 is too large; maximum is 17. ) [_orig] => Array ( [zoom] => 20.25 ) )

The values were fixed. Let's re-run the method getUrls:
$oMaphelper->getUrls();
Array ( [google] => https://www.google.com/maps/@-22.7405789,-47.3313609,17z [map1eu] => [mapillary] => https://www.mapillary.com/app/?lat=-22.7405789&lng=-47.3313609&z=17 [fligthtradar24] => https://www.flightradar24.com/-22.7405789,-47.3313609/17 [osm] => https://www.openstreetmap.org/#map=17/-22.7405789/-47.3313609 [wikimapia] => http://wikimapia.org/#lang=en&lat=-22.7405789&lon=-47.3313609&z=17&m=b [windy] => https://windy.com/?-22.7405789,-47.3313609,17 [yandex] => https://yandex.ru/maps/?ll=-47.3313609%2C-22.7405789&z=17 )

link generation with position data

With latitude, longitude and zoom you can generate links too.
To get links to all providers:

$oMaphelper->generateUrls(-22.7405789, -47.3313609, 20.25)
Array ( [google] => https://www.google.com/maps/@-22.7405789,-47.3313609,20.25z [map1eu] => [mapillary] => [fligthtradar24] => [osm] => [wikimapia] => [windy] => [yandex] => )

... or just one provider

$oMaphelper->generateUrl("google", -22.7405789, -47.3313609, 20.25)
https://www.google.com/maps/@-22.7405789,-47.3313609,20.25z

Examples

Click one :-)
http://www.openstreetmap.org/#map=13/46.9384/7.4585
https://www.yandex.ru/maps/99/munich/?ll=11.555422%2C48.085201&z=10
https://www.google.ch/maps/@46.9457237,7.4302919,14z
https://www.google.com.br/maps/@-22.7405789,-47.3313609,20.25z

Ressources
Source: Github / Author: Axel Hahn (www.axel-hahn.de)