HOW TO add Google Map API key?
Posted: Nov 28th, '12, 16:30
There is a Google Maps module in the last version (2.1.1), that requires using of Google Maps API Key.
The Static Maps API uses an API key to identify your application.
API keys are managed through the Google APIs console. To activate the Static Maps API and create your key:
1. Visit the APIs console at https://code.google.com/apis/console and log in with your Google Account.
2. Click the Services link from the left-hand menu, then activate the Static Maps API service.
3. Once the service has been activated, your API key is available from the API Access page, in the Simple API Access section.
4. Static Maps API applications use the Key for browser apps.
5. Enter generated key on your Modules » Google Maps » Google Maps Settings page
REMEMBER: Google has changed API2 (deprecated) to API3.
To fix this issue with retrieving address coordinates manually do following (fixed in v2.2.0 or higher):
1. Open include/classes/DoctorAddresses.class.php, find there UpdateCoordinates() class
2. API code with following:
You may also read Google API Tutorial:
https://www.w3schools.com/graphics/google_maps_intro.asp
The Static Maps API uses an API key to identify your application.
API keys are managed through the Google APIs console. To activate the Static Maps API and create your key:
1. Visit the APIs console at https://code.google.com/apis/console and log in with your Google Account.
2. Click the Services link from the left-hand menu, then activate the Static Maps API service.
3. Once the service has been activated, your API key is available from the API Access page, in the Simple API Access section.
4. Static Maps API applications use the Key for browser apps.
5. Enter generated key on your Modules » Google Maps » Google Maps Settings page
REMEMBER: Google has changed API2 (deprecated) to API3.
To fix this issue with retrieving address coordinates manually do following (fixed in v2.2.0 or higher):
1. Open include/classes/DoctorAddresses.class.php, find there UpdateCoordinates() class
2. API code with following:
Code: Select all
$address = urlencode($address);
$url = 'http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
$latitude = $response_a->results[0]->geometry->location->lat;
$longitude = $response_a->results[0]->geometry->location->lng;
You may also read Google API Tutorial:
https://www.w3schools.com/graphics/google_maps_intro.asp