Restrict geo lookup using google API

More
5 years 10 months ago #41965 by davidmarshall15
Hi,

I don't have a key and it seems google is becoming more restrictive on the number of updates.
To workaround this, I am having new members register with their city+country, this is enough for the sites purpose.

Then in geocoder I have set to only update if the coords are null but it is still making an API call.

For the next release can you update the geocodeUser function to this:
Code:
function geocodeUser($user,$cbUser) { if(JFactory::getUser()->id != $cbUser->user_id){ return; } $db = JFactory::getDbo(); $params = $this->params; $mode = $params->get('mode',0); if ( ($mode==1 && ($cbUser->cb_geolat == '' || $cbUser->cb_geolng == ''))||$mode==0 ) { $place = $this->geocodeAddress($params , $cbUser); $cbUser->cb_geolat = $place['latitude'] ? $place['latitude'] : $cbUser->cb_geolat; $cbUser->cb_geolng = $place['longitude'] ? $place['longitude'] : $cbUser->cb_geolng; $q ="UPDATE #__comprofiler SET cb_geolat='".$cbUser->cb_geolat."',cb_geolng='".$cbUser->cb_geolng."' WHERE id='".$cbUser->user_id."'"; $db->setQuery($q); $db->execute(); } }

All I have done is move the geocodeAddress call to inside the mode+empty coords check.

Thanks
David

Please Log in or Create an account to join the conversation.

Time to create page: 0.307 seconds
Powered by Kunena Forum
Disclaimer: Nordmograph is not affiliated with or endorsed by The Joomla! Project™. Any products and services provided through this site are not supported or warrantied by The Joomla! Project or Open Source Matters, Inc. Use of the Joomla!® name, symbol, logo and related trademarks is permitted under a limited license granted by Open Source Matters, Inc.