PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-03-10 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 145 All time: 8,757 This week: 361Up
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
  Performance   Level  
Name: Axel Hahn <contact>
Classes: 5 packages by
Country: Switzerland Switzerland
Age: 47
All time rank: 278726 in Switzerland Switzerland
Week rank: 695 Up10 in Switzerland Switzerland Up
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 maphelperExternal page  

Open in a separate window

  Files folder image Files  
File Role Description
Plain text file ahmaphelper.class.php Class Class source
Accessible without login Plain text file ahmaphelper.maps.php Aux. Auxiliary script
Accessible without login Plain text file demo.php Example Example script
Accessible without login Plain text file readme.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:145
This week:0
All time:8,757
This week:361Up