ah Map Helper: Parse URLs of map services and get their location

Recommend this page to a friend!
  Info   Example   Demos   View files (4)   Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 153 All time: 8,800 This week: 282
Version License PHP version Categories
ah-map-helper 1.0GNU General Publi...5PHP 5, Geography, Parsers
Description Author

This class can parse URLs of map services and get their location.

It can take URLs of maps from Google Maps, Yandex and Open Street map and extract the location coordinates and other parameters.

The class can also regenerate the URLs of map pages of any the supported services given the location coordinates and zoom level.

Innovation Award
PHP Programming Innovation award nominee
May 2016
Number 14
There are several types of mapping applications on the Web that can show specific locations given a URL that represents that location. However, each application uses different URL parameters to represent the location coordinates.

This class provides a general solution to extract location coordinates from map URLs of Google Maps, Yandex maps and OpenStreetMap.

It can also also do the opposite, i.e. given the coordinates of a location it can generate URLs to show that location in the different mapping sites that it supports.

Manuel Lemos
Picture of Axel Hahn
  Performance   Level  
Name: Axel Hahn <contact>
Classes: 5 packages by
Country: Switzerland Switzerland
Age: 48
All time rank: 274926 in Switzerland Switzerland
Week rank: 131 1 in Switzerland Switzerland
Innovation award
Innovation award
Nominee: 2x

Details
-------------------------------------------------------------------------------

ahmaphelper

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

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


Licence GPL 3.0

author: Axel Hahn
https://www.axel-hahn.de

see DEMO
https://www.axel-hahn.de/demos/maphelper/

DOCS
https://www.axel-hahn.de/docs/ahmaphelper/index.htm

-------------------------------------------------------------------------------

2016-04-17  1.0  first public release
2016-05-25  1.1  added options minzoom; new methods getUrls() + fixPosition()
2017-01-15  1.2  added  support for regional maps (provider map1eu)

-------------------------------------------------------------------------------

USAGE:

require_once 'ahmaphelper.class.php';
$oMaphelper = new ahmaphelper();

(1)
get a position from url:
go to a map provider:
  https://www.google.ch/maps
  http://www.openstreetmap.org/
  https://yandex.ru/maps/
Zoom in, go to any position and copy the url

$aPos = $oMaphelper->getPos($sUrl);

(2)
generate urls with the same position
print_r($oMaphelper->getUrls());

(3)
fix position data to be compatible to all map providers. 
print_r($oMaphelper->fixPosition());
print_r($oMaphelper->getUrls());

(4)
manually generate links with position data and zoom level (returns an array):
print_r($oMaphelper->generateUrls($aPos['lat'], $aPos['lon'], $aPos['zoom']));

(5)
manually generate link with position data and zoom level to a given provider 
(returns a string):
echo $oMaphelper->generateUrl([provider], $aPos['lat'], $aPos['lon'], $aPos['zoom']);
echo $oMaphelper->generateUrls("google", $aPos['lat'], $aPos['lon'], $aPos['zoom']);

(6)
helper functions:

  generate url with the same position to a specific provider
  $oMaphelper->getProviders()
  ... returns names of known providers

  $oMaphelper->getMinZoom()
  ... returns lowest maxzoom level of all providers

-------------------------------------------------------------------------------
  demo maphelper  

Open in a separate window

  Files  
File Role Description
ahmaphelper.class.php Class Class source
ahmaphelper.maps.php Aux. Auxiliary script
demo.php Example Example script
readme.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:153
This week:0
All time:8,800
This week:282

For more information send a message to info at phpclasses dot org.