Skip to content

Conversation

@sparky672
Copy link

@sparky672 sparky672 commented Apr 15, 2018

My hosting company, for security reasons, is forcing PHP setting allow_url_fopen to FALSE, thereby disabling file_get_contents() in the get_lat_long_from_address() function. This forces a total failure of the geocoding function, which then only returns 0,0 for Lat/Lng, thereby setting all maps in the middle of the ocean off the western coast of Africa.

The only solution, other than new hosting, was to replace the file_get_contents() line with cURL as per the following.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

$data = json_decode($output);

Secondly, due to constant JavaScript warnings, I've removed all traces of the obsolete sensor parameter as per recommendation by Google:

Google Documentation: Sensor Not Required


Finally, I've set the default value for the $https variable to TRUE as per recommendation by Google:

Google Documentation: HTTPS or HTTP

My hosting company, for whatever reason, is forcing PHP setting `allow_url_fopen` to `FALSE`, thereby breaking `file_get_contents()` in the `get_lat_long_from_address()` function.  This forces a total failure of the geocoding function, which then only returns "0,0" for Lat/Lng, thereby setting all maps in the middle of the ocean off the western coast of Africa.

The only solution, other than new hosting, was to replace `file_get_contents()` with cURL.

--------

Secondly, I've removed all traces of the obsolete `sensor` parameter as per Google:

https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required

--------

Finally, I've set the `$https` variable to `TRUE` by default as this is the recommendation by Google:

https://developers.google.com/maps/documentation/javascript/tutorial#https-or-http
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant