This Fieldtype for ProcessWire 2.1+ holds an address or location name, and automatically geocodes the address to latitude/longitude using Google Maps API.
This Fieldtype was also created to serve as an example of creating a custom Fieldtype and Inputfield that contains multiple pieces of data.
Download at: https://github.com/r...ldtypeMapMarker
How to Use
To use, install FieldtypeMapMarker like you would any other module (install instructions: http://processwire.c...wnload/modules/). Then create a new field that uses it. Add that field to a template and edit a page using that template. Enter an address, place or location of any sort into the 'Address' field and hit Save. For example, Google Maps will geocode any of these:
- 125 E. Court Square, Decatur, GA 30030
- Atlanta, GA
- Disney World
On the front end, you can utilize this data for your own Google Maps (or anything else that you might need latitude/longitude for).
Lets assume that your field is called 'marker'. Here is how you would access the components of it from the API:
<?php echo $page->marker->address; // outputs the address you entered echo $page->marker->lat; // outputs the latitude echo $page->marker->lng; // outputs the longitude
Of course, this Fieldtype works without it's Inputfield too. To geocode an address from the API, all you need to do is set or change the 'address' component of your field, i.e.
<?php $page->marker->address = 'Disney Land'; $page->save(); // lat/lng will now be updated to Disney Land's lat/lng













