Field that stores an address with latitude and longitude coordinates and has built-in geocoding capability with Leaflet Maps API.
This is a port of the Map Marker Fieldtype by Ryan Cramer. Instead of Google maps it uses Leaflet maps.
Google maps geocoding is still used for geocoding default lat/lng values under field settings but the geocoding on page editing uses Per Liedmans [leaflet-control-geocoder] (https://github.com/perliedman/leaflet-control-geocoder)
This Fieldtype for ProcessWire holds an address or location name, and automatically geocodes the address to latitude/longitude using leaflet-control-geocoder. The resulting values may be used to populate any kind of map (whether Leaflet Maps or another).
Support for per-marker customisation of visuals and popup content is included.
Copy all of the files for this module into /site/modules/FieldtypeLeafletMapMarker/
In your admin, go to the Modules screen and "check for new modules." Under the 'Fieldtype' section, install the 'Leaflet Map Marker' module (FieldtypeLeadletMapMarker)
Under the 'Inputfield' section, install the 'Leaflet Map Marker' module (InputfieldLeafletMapMarker) if it is not already installed.
Under the 'Markup' section, install the 'Leaflet Map' module (MarkupLeafletMap) and the 'Inline Scripts' module (MarkupAddInlineScript)
In your admin, go to Setup > Fields > Add New Field. Choose LeafletMapMarker as the type. If you are not sure what to name your field, simply "map" is a good one! Once created, configure the settings on the input tab.
Add your new "map" field to one or more templates, as you would any other field.
Create or edit a page using one of the templates you added the "map" field to.
The geocoding also works in reverse. You may drag the map marker wherever you want and it will populate the address field for you. You may also populate the latitude, longitude and zoom fields manually if you like. Unchecking the box between address and latitude disables the geocoder.
If the geocoding does not work, please ensure that your browser is not blocking the execution of any scripts.
In your template files, you can utilize this data for your own Leaflet Maps (or anything else that you might need latitude/longitude for).
Lets assume that your field is called 'map'. Here is how you would access the components of it from the API: