1. Docs
  2. User Guide
  3. Maps, Co-ordinates and Geocoding

Maps, Co-ordinates and Geocoding

Back in July 2018, Google got stricter with their Google Maps API usage. We wrote about this here.

In short, it meant that an API key with the right permissions would always be required when doing anything relating to maps or geocoding.

Within Property Hive there are a number of places that we use maps or geocoding. To name a couple:

  • The [property_map] shortcode
  • Automatically obtaining the co-ordinates for a property when entered into Property Hive
  • The Map Search add on
  • The Radial Search add on
  • The Property Import add on when importing properties using a format that doesn’t provide the co-ordinates so we have to go off and obtain them ourselves.

If you’re experiencing issues with any of the above there are 2 things to check:

  1. That you have a Google Maps API key entered in WordPress under ‘Property Hive > Settings > General > Map’. Keys can be obtained here.
  2. If you’re using any of the geocoding functionality, that the API key entered has not only the JavaScript API enabled, but also the separate Geocoding API library. To do this, visit your API console and navigate to ‘Libraries’. Do a search for ‘Geocoding’, click into the library and click the ‘Enable‘ button.

Debugging Maps Not Displaying Correctly

If you’ve having issues with maps not displaying or showing errors, by far the best way to debug this is view the console. In most browsers you can do this by pressing F12 then navigate to ‘Console’ where you will likely see an error relating to the maps.

It could be that the API is missing or invalid, or maybe Google Maps is being included multiple times on the page. Either way, by checking the console you should right away what the cause of the map not displaying is.

Debugging Geocoding Not Working

Geocoding not working is slightly more difficult to debug but in 99.9% of cases it’s because of a missing API key or an API key that doesn’t have the Geocoding library enabled as mentioned higher up this page.

A quick way to test this is to visit a link like so:

https://maps.googleapis.com/maps/api/geocode/xml?address=london&sensor=false&region=gb&key={your-key-here}

If the key isn’t valid you’ll get an error message displayed.

Was this article helpful to you? Yes No