You can download a zip file and extract it
OR
if you use a version control client you can checkout the sources of the project.
It will make it easier to keep the files up to date.
Checkout sources with git client.
The following commands create a directory ahmaphelper below webroot and put all files there:
cd [webroot-directory]/[install-dir]/
git clone https://github.com/axelhahn/ahmaphelper.git [optional-name-of-subdir]
Leaving [optional-name-of-subdir] empty will create a subdir named "ahmaphelper"
Get the latest version:
Download
Extract the 2 ahmaphelper*.php files somewhere below webroot on your webserver. You can put to any (but the same) subdirectory.
No parameter is required.
require_once 'ahmaphelper.class.php'; $oMaphelper = new ahmaphelper();
You can use one of the existing map providers.
Zoom in, go to any position and copy the url.
$oMaphelper->getPos("https://www.google.ch/maps/@46.9465944,7.4439426,19.25z");
You get the name of the detected map provider and the fetched position.
Array ( [source] => https://www.google.ch/maps/@46.9465944,7.4439426,19.25z [provider] => google [lat] => 46.9465944 [lon] => 7.4439426 [zoom] => 19.25 )
To get all links to all providers
print_r($oMaphelper->getUrls());
Array ( [google] => https://www.google.com/maps/@46.9465944,7.4439426,19.25z [map1eu] => [mapillary] => https://www.mapillary.com/app/?lat=46.9465944&lng=7.4439426&z=19.25 [fligthtradar24] => [osm] => [wikimapia] => [windy] => [yandex] => )
What can happen is that you do not get all links. The reason is:
different map providers have a different max. zoom level and
not all can handle zoom level as float.
There is a method to fix position data to be compatible to all map providers.
It returns an array that contains subkeys
_warnings with the made fixes and
_orig with original values.
print_r($oMaphelper->fixPosition());
Array ( [source] => https://www.google.ch/maps/@46.9465944,7.4439426,19.25z [provider] => google [lat] => 46.9465944 [lon] => 7.4439426 [zoom] => 17 [_warnings] => Array ( [0] => zoom level is not integer. [1] => zoom level 19.25 is too large; maximum is 17. ) [_orig] => Array ( [zoom] => 19.25 ) )
Then call getUrls() again:
print_r($oMaphelper->getUrls());
Array ( [google] => https://www.google.com/maps/@46.9465944,7.4439426,17z [map1eu] => http://beta.map1.eu/#zoom=17&lat=46.9465944&lon=7.4439426&layers=BT [mapillary] => https://www.mapillary.com/app/?lat=46.9465944&lng=7.4439426&z=17 [fligthtradar24] => https://www.flightradar24.com/46.9465944,7.4439426/17 [osm] => https://www.openstreetmap.org/#map=17/46.9465944/7.4439426 [wikimapia] => http://wikimapia.org/#lang=en&lat=46.9465944&lon=7.4439426&z=17&m=b [windy] => https://windy.com/?46.9465944,7.4439426,17 [yandex] => https://yandex.ru/maps/?ll=7.4439426%2C46.9465944&z=17 )
You can generate links
Manually generate links with position data and zoom level (returns an array).
You get the links to all known providers - it returns an array:
print_r($oMaphelper->generateUrls($aPos['lat'], $aPos['lon'], $aPos['zoom']));
... or to a single provider - it returns a string
echo $oMaphelper->generateUrl([provider], $aPos['lat'], $aPos['lon'], $aPos['zoom']); echo $oMaphelper->generateUrl("google", $aPos['lat'], $aPos['lon'], $aPos['zoom']);
To get names of known providers that you can use in generateUrl():
$oMaphelper->getProviders();
Array ( [0] => google [1] => map1eu [2] => mapillary [3] => fligthtradar24 [4] => osm [5] => wikimapia [6] => windy [7] => yandex )
Get lowest maxzoom level of all providers
$oMaphelper->getMinZoom()
17