Re: Geocoder isn't auto-generate latitude and longitude coordinates

By Mikey - December 18, 2020

In response to: https://www.interactivetools.com/forum/forum-posts.php?postNum=2244377#post2244377

I have the Geocoder Plugin V1.05 install, running on CMSBulder V3.06 and I set up a Google API credentials and applied the API Key to geocoder... but geocoder just wont auto-generatelatitudeandlongitudecoordinates on my websites. 

I have a CC on file with Google APIs, I also have the following enabled:

  • Maps Embed API - Make places easily discoverable with interactive Google Maps.
  • Maps Static API - Simple, embeddable map image with minimal code.
  • Maps JavaScript API - Maps for your website
  • Geocoding API - Convert between addresses and geographic coordinates.

I also removed all API Key Restrictions, to see if that may be the cause of my woes.

I double checked my field type, geocoder to ensure the field names match... and these all check out fine.

I also tried the "Geocode Tables" (Admin > Plugins > Geocode Tables, and selected the table which needs to be
updated.) but got the following message:Error: STATUS_REQUEST_DENIED

No joy. 

Has anyone else had this issue and/or have suggestions on how to get geocoder to auto-generatelatitudeandlongitudecoordinates?

By Jenna - January 27, 2021

Hi Zicky,

Just taking a look at this old post. Is this still an issue you need help figuring out or did you sort it out yourself/with the support ticket?

Please let me know if we can help you.

Jenna Cooke - PHP Programmer
interactivetools.com

By Jenna - January 27, 2021

Hi Zicky,

I'd be happy to try to get to the bottom of this with you. I just need to confirm which version of the Geocoder plugin you're using and on which version of cmsbuilder? In this post you say v1.05 and v3.06 respectively but on https://www.interactivetools.com/forum/forum-posts.php?postNum=2244363#post2244363 you say latest and v3.53.

I want to ensure I am using the same version as you are when I try to see what my settings are versus yours.

We are working on getting appropriate documentation for setting up the Google API keys, as it is far too confusing for everyone (myself included sometimes).

Let me know which versions you're using and I'll do my best to help you out.

Thanks!

Jenna Cooke - PHP Programmer
interactivetools.com

By Mikey - January 27, 2021

Hey Jenna,

The CMS is version v3.06 (Build 2101)

The Geocoder plugin is v1.05

The plugin has the following modification shown below. I just replaced Geocoder with a clean copy without the modification below and it did not throw the "Status_Request_Denied" error message. I then added back the modification and it threw the error again. I think it's safe to say somethings wrong with the modification below that looks for 'property_street_address, property_city, property_state, property_zip' which needs to be fixed. Any suggestions?

$GLOBALS['GEOCODER_ADDRESS_FIELD_COMBOS'] = array( // values should be ", " separated. alternates should be "/" separated.
  'address, city, province/state, postcode/zipcode/zip',
  'city, province/state, postcode/zipcode/zip',
  'province/state, postcode/zipcode/zip',
  'address, city, province/state, country',
  'address, city, province/state',
  'postcode/zipcode/zip/address',
	'property_street_address, property_city, property_state, property_zip'
);

Thanks, Zicky

By Jenna - January 27, 2021

Hi Zicky,

Please give this a try: 

$GLOBALS['GEOCODER_ADDRESS_FIELD_COMBOS'] = array( // values should be ", " separated. alternates should be "/" separated.
  'address, city, province/state, postcode/zipcode/zip',
  'city, province/state, postcode/zipcode/zip',
  'province/state, postcode/zipcode/zip',
  'address, city, province/state, country',
  'address, city, province/state',
  'postcode/zipcode/zip/address',
  'property_street_address/address, property_city/city, property_state/state, property_zip/zipcode'
);

I'm wondering if since you're declaring a new set of field combinations that the plugin doesn't understand what you're trying to do and therefore Google cannot figure it out either. By adding the alternates accepted by Google, it may wind up working properly.

Please let me know if this is helpful and if not, I will continue looking.

Jenna Cooke - PHP Programmer
interactivetools.com

By Mikey - January 27, 2021

Hey Jenna,

I gave that a try, but it still isn't generating the geo coordinates.

By Jenna - January 27, 2021

Hi Zicky,

I downloaded the version of the Geocoder plugin (v1.05) and it doesn't include the API Key for use in the maps api call.

// Changed Line 123 from $url = "https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" . urlencode($address)
// To below:
$url = "https://maps.googleapis.com/maps/api/geocode/json?address=" .urlencode($address);
// Include the GEOCODER API KEY, added this
if (@$GLOBALS['GEOCODER_GOOGLE_API_KEY']!= '') {
  $url .= "&key=".$GLOBALS['GEOCODER_GOOGLE_API_KEY'];
}
//This stays so it gets added if it exists
if (@$GLOBALS['GEOCODER_REGION']) {
  $url .= "&region=" . urlencode($GLOBALS['GEOCODER_REGION']);
}

Normally, I wouldn't suggest updating a plugin below the line that says not to update below... but this is an outdated version of the plugin. In later releases, it got updated to properly use the GEOCODER_GOOGLE_API_KEY.

That being said, I tested locally and finally got it to work (after it getting the denied status many times). I also utilized other fields like the ones we tried earlier, using the slash (/) between your field names and the Google-understood fields.

Please give this a shot.

Note that when you update to a more recent version of Geocoder in the future, it should be self-resolved.

Jenna Cooke - PHP Programmer
interactivetools.com

By Mikey - January 27, 2021

Hey Jenna,

That did the trick... geocoder is spinning off the coordinates now.

Thank you so much!!

Zicky