Closed alexrollin closed 3 years ago
Is it possible to allow Google for Geocoding even if OSM is selected as the Maps API?
Added new hook to filter API used to get address from GPS. https://github.com/AyeCode/geodirectory/commit/89b9d7ea96686a5f389ee04b6cdfc25ea5210b33#diff-5147394367773dee85450faa4945b20aR219
Here examples:
/**
* Filter Geocode API used to get GPS from post address.
*/
function gd_snippet_post_gps_from_address_api( $api ) {geodir_error_log( $api, 'gd_snippet_post_gps_from_address_api', __FILE__, __LINE__ );
$api = 'google'; // google or osm
return $api;
}
add_filter( 'geodir_post_gps_from_address_api', 'gd_snippet_post_gps_from_address_api', 20, 1 );
/**
* Filter Geocode API used to get address from post GPS.
*/
function gd_snippet_post_address_from_gps_api( $api ) {geodir_error_log( $api, 'gd_snippet_post_address_from_gps_api', __FILE__, __LINE__ );
$api = 'google'; // google or osm
return $api;
}
add_filter( 'geodir_post_address_from_gps_api', 'gd_snippet_post_address_from_gps_api', 20, 1 );
Above PHP snippets will force to use specific API to get GPS from address & to get address from GPS during import listing & insert dummy data.
Add listing page https://github.com/AyeCode/geodirectory/blob/2e4d5a382f1e2e9d399ebbdfd321de8fdcf84fa3/includes/class-geodir-maps.php#L53
/**
* Load Google map on add listing page.
*/
function gd_snippet_map_name( $map ) {
if ( geodir_is_page( 'add-listing' ) ) {
$map = 'google'; // google or osm
}
return $map;
}
add_filter( 'geodir_map_name', 'gd_snippet_map_name', 20, 1 );
A member has reported and the team has confirmed that a a google api key with http referrer settings cannot access the geocoding API.
This necessitates some change to allow for a second key that does not have http referrer settings specifically for 'hidden' geocoding operations (that won't expose the unrestricted api key).
https://wpgeodirectory.com/support/topic/geocoding-importing-and-google-maps-api-restrictions/#post-493432
Of note, many members have also requested the ability to use google for geocoding but using OSM for viewing maps. They want accurate addresses and lat lon but don't want to pay simply for map views.