This module allows your businesses that list in Business Directory to have a Google Map for their address. You can map the address fields from any field you’ve added in the Form Fields section. You can also choose the map type (satellite, hybrid, terrain, street view) and the size of the map, as well as markers to display.
The map can be displayed on any of the following views:
- The Directory (and List) Page (showing all visible listings)
- The Search Page (showing all listings in the results)
- The Detail Page (showing the current listing’s map only)
Installation
Follow the installation steps to get started.
Administration
Google Maps admin screen is broken into 3 sections. The top one is general settings:
General Settings–these settings control where you maps are allowed to show up in the directory
- Turn on Google Maps Integration: Activates or deactivates the map displays on the listing views. Must be on to show the maps for the listing’s address fields. On by default.
- Google Maps API Key (REQUIRED): Enter your Geocoding API key here from Google. See below for more details about getting and using one.
- Show listings map in categories?: Activates or deactivates the map that shows on the category page. On by default.
- Show listings map in View Listings?: Activates or deactivates the map that shows on the Directory/List page. On by default.
- Show listings map in search results?: Activates or deactivates the map that shows on the Advanced Search page. On by default.
- Current page listings to show on map: This allows you to control whether the map shows ALL listings in your directory or just the listings on the active page. If you have a LARGE directory, then changing this to “active page” will improve performance. Some large directories require too much processing to pull all markers on the map at once so this allows you to control that.
- Allow visitors to get directions to listings: Turning this on will show “Get directions” where the user can enter their current address and the map will display turn-by-turn directions and a route to get to that particular listing's location. Please note–Google's API requires that secure HTTP connections (https) are used, so if your site is not using SSL, you may see warnings about https redirects. This is not a bug with BD, but a problem where your site is not compatible with Google's API unless you make it fully secure (SSL).
- Allow visitors to manually adjust the location of their listings: Turning this on will allow users on the FRONT END only to manually move a marker to a physical location on a map. This is useful if you have clients with addresses in rural areas where Google Maps doesn't place the marker in the “proper” place.
The next section is about the appearance of the maps:
Appearance–these settings control how your maps will appear in the directory
- Display Map Position: Allows you to control where the map appears in the listing pages. Choices: Above All Listings or Below All Listings. Default is Above All Listings
- Map Size: The dimensions of the Google Map to display, either Large (400×600), Small (200×300) or Custom Size. Default is Automatic If your map does not fit in the width of the map, use “custom” and set the size you want. Automatic allows mobile and desktop users to receive the proper sizing and is the recommended setting.
- Custom Map Size Width: The custom width of the Google Map to display. Only valid when Map Size “Custom” is selected
- Custom Map Size Height: The custom height of the Google Map to display. Only valid when Map Size “Custom” is selected
- Auto resize map when container is stretched: Turn this on to make your maps fully responsive on mobile displays where tablets and phones have wildly different sizes.
- Map Type: One of the following choices: Road Map, Satellite, Terrain or Hybrid. Road Map will display the labeled streets in a colored map. Satellite and Terrain will use the images from Google Earth. Hybrid overlays the two.
- Animate markers? Turns on basic Google Map animations for the markers where the business is located.
And the last section is regarding which fields to use for the map address information.
Field Options–these are the mappings of where Google Maps will pull its address data from using your listing fields defined under Form Fields. You can map up to 5 different fields to use. Google Maps requires at least one to be mapped.
- Address: Which field in your list of form fields maps to the base address
- City: Which field in your list of form fields maps to the city
- State: Which field in your list of form fields maps to the state
- Country: Which field in your list of form fields maps to the country
- ZIP/Postal Code: Which field in your list of form fields maps to the postal code
Using an API Key for Google Maps
What is the API key?
API keys allow developers and site owners to track usage of Google’s services on their sites via Google’s APIs Console.
Most of Google’s free services are limited to a given number of views, page loads, etc. This means that when your site goes over those limits the services will stop working on your site.
By using an API key (coupled with “Automated Billing”) you can prevent any interruption due to usage: when you hit a given limit, Google will charge you for the extra usage while your site keeps working.
In the specific case of the Google Maps APIs, the limits are as follows:
- 25,000 map views per day.
- 2,500 geolocation requests per day.
- 5 requests (of any kind) per second.
Why do I need API keys for the Google Maps module?
Most sites shouldn’t need API keys at all since limits on Google Maps APIs are very reasonable. Because limits are enforced during 24-hour intervals, even if your site goes over the limit, it could be the case that the outage lasts at most until the next day.
The Business Directory – Google Maps module uses a special kind of cache to prevent unnecessary API usage but sometimes that’s not enough.
If, after enabling the module, some or all of your maps are not being displayed and you’ve been seeing a warning about failed requests on your WP backend for more than 24 hours, you definitely need an API key.
If your maps are not being displayed but you’re not seeing a warning on the backend, you probably don’t need an API key. Please double check your settings and, if the problem persists, contact us for assistance.
If you have shared hosting, READ THIS:
When your site is on shared hosting, as the name suggests, it is sharing the same physical server resources (such as memory, CPU, etc.) with several other sites. Because all of those sites are on the same server, most of the time they’re also sharing the same IP address, regardless of the domain names being different.
Google enforces limits by looking at the IP address of your server so your site could be denied access to Google APIs even if it is not the one abusing the APIs or hitting the limits on its traffic alone.
An API key is a way to solve this issue without having to move your site to a dedicated server or VPS.
How do I get an API key from Google for use with the Google Maps module?
First, you’ll need a Google login, such as the one from a gmail.com account, and a credit card for billing.
- Visit Google Developers Console and enter your login information (if asked).
- If there are no projects listed, create a new one or select your current project.
- Go to APIs & Services → Dashboard and click + Enable APIs and Services. Make sure the following APIs are enabled:
- Google Maps Geocoding API. (NOTE: Don’t confuse this with Geolocation–they aren’t the same!)
- Google Maps JavaScript API v3
- Maps Embed API (NOTE: If you require the directions feature, then Directions API should be enabled.)
- Go to APIs & Services → Credentials and click Create Credentials. Choose API Key as the key type. You can also add IP restrictions to your key (not recommended)
- Your new API key should be created (a long string of characters and numbers).
- (Optional) We suggest you set up automated billing for your project to avoid any outage because Google may require it. To do that, visit “Billing & settings” under your project’s name and click Enable billing.
- Log in to your site’s WP admin and visit Directory → Settings → Google Maps to enter your new API Key.
Note:
Google has a new process for getting an API key. Customers have to add billing information, and they also must select from among three different products:
If you will use the “Directions” feature (shown below) in the Maps module, you also need to select the “Directions API” option.
API Key References
- Google Developers Console Help
- Geocoding API usage limits
- Usage Limits for Google Maps API Web Services
Google Maps in action
Once you’ve defined the map fields and activated the module, you should see this appear on a single listing view:
This particular display is with the “Large Map” and “Roadmap” settings on. The fields “Address”, “City” and “State” are used to map the location of Apple Computer here.
Troubleshooting
API Key Activation in Google Maps
There are three key areas where people run into trouble with activating their API keys when implementing the Google Maps Module.
- Make sure all 3 APIs are added. The Google Maps Module requires three API keys, which are outlined in this article. To recap, here are the three that you need:
- Google Maps Geocoding API. (NOTE: Don’t confuse this with Geolocation–they aren’t the same!)
- Google Maps JavaScript API v3
- Maps Embed API (NOTE: If you require the directions feature, then Directions API should be enabled.)
2. Make sure you have selected no restrictions. Please also select “None” in restrictions for each of these keys. This part is important since the module does not seem to work using the HTTP referrer or IP address.
3. Make sure you have billing turned on. The other issue is that Google made changes to its Maps usage accounts, and they have started requiring a payment method to be put on file. There is more information about the changes and how they may affect you at this link: https://cloud.google.com/maps-platform/user-guide/pricing-changes/ There is also a pricing sheet here for your reference: https://cloud.google.com/maps-platform/pricing/sheet/
The billing issue is the most common error we see. Here is the typical warning that Google gives you: You must enable Billing on the Google Cloud Project at https://console.cloud.google.com/project/_/billing/enable Learn more at https://developers.google.com/maps/gmp-get-started
Simple steps you can take to find the reason for the error
- Go to a page on your site where Google Maps is supposed to show.
- Right-click on the page.
- Choose Inspect from the dropdown.
- View the Console tab.
- You will see the error there if there is one.
I am getting blank maps
Blank maps can happen for a variety of reasons. Here are some possibilities:
1) You recently imported a large number of listings. If you did this, the Google Maps API has a daily limit of calls made to it and can be exceeded during the process. Waiting 24 hours usually takes care of the problem as you'll get a new allocation of calls the next day. Once BD's Maps module can get the geolocation data, we cache it. This is probably the most common cause.
2) You're using a theme or other plugin that is using the Google Maps API as well. The limit is imposed for all calls made from the server, so if your other software has used them up for the day, the map is blank until it can get the data. This is less common but can happen.
3) You're on a shared hosting plan and someone else is using the Google Maps API on your server besides you. The calls are allocated per IP address, so a shared host means shared calls. This is the least common, but we see it occasionally.
4) You haven't mapped the listing fields on the Maps tab OR your listing doesn't have any address/location data. Without anything to locate with, the Map won't actually appear.
In the first two cases, the first thing to do is wait 24 hours and see if the maps appear on their own. If not, then the next thing to check is to see if the Maps are having some kind of conflict, but it's best to know if they restore on their own first.