Versione Italiana

Map widget

The widget allow to insert a map from google map, reading data from datasource for show overlays like marker, line, polygons.

System requirements

Google allow using of a javascript API for insert inside a page a dinamic map. To this map is possible to add one or more ovelays, like markers (special icons for highlight a point), lines and polygons.
For using this service is needed a key (for free) that will be passed as parameter to API call, that will be associated to the domain used in page url.
In following examples the key may be used for urls like http://localhost.

All coordinates used for map and overlays must be geographic longitude and latitude, no such simple for umans.
In p4a_map we prefer use conventional address: this is possible, thanks to Ajax function that querying google database return to a callback function geografical lat/lan used to dinimically update map and overlays.
So, before use an address, is better testing on Google Map site form avoid duplication or losing of coordinates.

Screenshots

:contribs:p4a_map-0.1.jpg

Features

  • Using specify coordinates like uman readable address
  • Size, center and zoom of map settable
  • Allow adding markers on map for hightlight point ad get info on mouse over event

Sample code

You view an example of code in the file GoogleTest.php of the downloaded package.

Code reference

For using p4a_map, are avaiable this methods:

Method Parameters Description
setCenter string $address set addres for the center of map
getCenter read center address of map
setZoom int $zoom set initial zoom (from 1 to 17)
getZoom read initial zoom
setKey string $key set key to pass at Goggle Map API
setWidth int $width
string $unit
wrapper to standard widget method
setHeight int $height
string $unit
wrapper to standard widget method
string getWidth wrapper to standard widget method
string getHeight wrapper to standard widget method
addMarker string $address
string $info
set manually a marker to address
and show, moving mouse over, the info gived
setSourceAddressField string $name set name of source field used for address of marker
string getSourceAddressField read name of source field used for address of marker
setSourceDescriptionField string $name set name of source field used for address of marker
string getSourceDescriptionField get name of source field used for address of marker
setSource data_source $src set data source used for get markers data
data_source getSource get data source used for get markers data

More documentation

Change Log

Rel 0.1 2007/10/17

  • Initial release

Rel 0.1.1 2007/10/22

  • Added setKey function for setting Google Map url’s key

Rel 0.1.2 2008/04/01

  • Major update: Now it’s possible to calculate distances from a given center location in a given radius
  • Markers could be added with or without passing geographic coordinates values
  • Coordinates could be passed manually or by a specific field in the datasource
  • Added setSourceCoordinatesField function for setting field name for geographic coordinates
  • Added getSourceCoordinatesField function that returns the name of the fields for geographic coordinates
  • Added getLocationCoordinates() functions that returns geographic coordinates of given location
  • javascript was reworked

Road Map

Rel 0.2

  • Implements icons for markers

Rel 0.3

  • Implementing lines and polygons overlay

Rel 0.4

  • Manage click events on map for return geo coordinates

Rel 0.5

  • Implement autocenter/autozoom based on overlay position

Download

For using widget include the files p4a_map.php and p4a_map.js like in this example.

Authors

 
contribs/p4a_map.txt · Last modified: 2008/04/01 02:56 by p4a
 
Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki