GoogleMapAPIv3
Questions answered by this recipe
Description
This is a trimmed down and modified Google Maps API based on Ben Wilson's original GoogleMapAPI.
Installation
- Put GoogleMapsv3.phpΔ in your cookbook directory.
- Put GoogleMapsv3.txtΔ in your pub directory and rename it to GoogleMapsv3.js (.js was not an allowed file extension for uploads).
- 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
Contributors
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.