GoogleMapAPIv3

Summary: This is a trimmed down and modified Google Maps API based on Ben Wilson's original GoogleMapAPI.
Version: 1.0
Prerequisites: None
Status: beta
Maintainer: Alex Eftimiades?
Users: (view? / edit)

Questions answered by this recipe

All sections are optional, you can remove those that do not apply to your recipe, and add new ones.

Description

This is a trimmed down and modified Google Maps API based on Ben Wilson's original GoogleMapAPI.

Installation

  1. Put GoogleMapsv3.phpΔ in your cookbook directory.
  2. Put GoogleMapsv3.txtΔ in your pub directory and rename it to GoogleMapsv3.js (.js was not an allowed file extension for uploads).
  3. Include GoogleMapsAPIv3.php in your cookbook directory with the following line:

include_once("$FarmD/cookbook/GoogleMapsv3.php");

Configuration

You can change the location of the address cache directory by setting the $CacheDir variable. The default is
$FarmD/pub/address_cache.

Usage

Use the (:Google-Marker options:) to put a marker on a map with options.
Use the (:Google-Map options:) markup to show a google map with options.

Marker options are

  • icon=the url of the icon to use. I recommend you use something like http://www.google.com/mapfiles/markerQ.png
  • lon=longitude
  • lat=latitude
  • text=the html text that will appear when you click the icon.
  • id=map id (the map the marker should go on). This defaults to "map"

(:Google-Marker icon=http://www.google.com/mapfiles/markerQ.png lat=45 lon=45 text='hello there':)

For a google map, the options are thrown right into an html div, so the options concerning its style and id are all the same as for an html div. You can just throw in a (:Google-Map:) somewhere if you have only one map. The default id is "map" (same for the markers).
Here is a complete example:
(:Google-Marker icon=http://www.google.com/mapfiles/markerQ.png lat=34 lon=23 text='hi there' id=firstMap:)
(:Google-Map id=firstMap:)

You can throw in as many maps and markers in whatever order you like.

Also, the php function AddressLookup($address) function can be used to get a lat,lon array from an address.

See also

GoogleMapAPI

Contributors

Alex Eftimiades?

Comments

See discussion at GoogleMapAPIv3-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.