What is Geolocation?
Geolocation is a Drupal module that allows users to include Google maps into custom content types once the installation and configuration steps are completed. It takes the map coordinates (latitude, longitude) and, via an API key, translates that information into a map generated dynamically into your pages.
Request the Geolocation Module for your site
The installation of the module requires the assistance of the SiteFarm team. Please submit a Service Request form and indicate your need for the Geolocation web service. When processing this step for you, the SiteFarm team will also enable the appropriate permissions for configuring your Geolocation settings.
Acquire a Google Map API Key
Visit the Google Maps Platform site's API key page and follow the instructions for obtaining an API key for your site.
Configure your Geolocations settings
- Once the module is enabled and the permissions set, navigate to Manage » Configuration » Web services section » Geolocation settings.
- Enter your API key in the field:
- Click the Save configuration button to finish.
Adding Geolocation to a custom content type
The default content types that come with SiteFarm (Article, Basic page, Event, Person, etc) are locked down and cannot be edited. This means you will need to create your own custom content type so you can include the Geolocation entity fields for your users to fill in.
- Once you've started your custom content type, click the + Add field button.
- Use the 'Add a new field' menu, scroll down and locate the General section, and select Geolocation.
- Provide a label name for the field. This will be visible to your users filling out the content type.
- Click save and continue.
- The next screen will ask you to indicate if the number of maps on the page should be unlimited or limited. If limited, but sure to indicate 1 or your specific number. These settings apply to the Geolocation field everywhere it is used. These settings impact the way the data is stored in the database and cannot be changed once data has been created, so be sure of your choice at the outset.
- Click Save field settings.
- The last screen will give you the option to update/provide:
- Label name
- Help text
- Indicate if it's a required field
- Enter a default value or leave the Latitude and Longitude fields blank
- Click Save settings.
- In the content type's overview, click on the Manage form display tab.
- Locate your Geolocations field in the list and, under the Widget column, change the menu item from Geolocation Lat/Lng to Geolocation Google Maps API - Geocoding and Map.
- In the content type's overview, click on the Manage display tab.
- Again, locate your Geolocations field in the list and, under the Widget column, change the menu item from Geolocation Lat/Lng to Geolocation Google Maps API - Map.
- In both steps 10 and 12, you have the option to click on the element's cog to access its configuration settings if further customization is desired in terms of title positioning, size, replacement tokens, and map settings.
- Click Save to finish.