Advertisement:

Author Topic: [Tip] Google Maps coordinates issue  (Read 824 times)

gnoe

  • Full Member
  • ***
  • Posts: 237
[Tip] Google Maps coordinates issue
« on: May 04, 2015, 12:04:29 pm »
This is a little hack I did to solve an issue with Regions in my osclass installation.

Problem:
I had some big regions with many cities and decided to make them more user-friendly by splitting them.
e.g Region - North, Region - South, Region - Center etc

Google maps couldn't locate them and send back coordinates to plugin.
Preferred the first part and not my additions, including hyphen.

So, d_coord_lat and d_coord_long fields were empty in oc_t_item_location table.

Solution:
google_maps plugin -> index.php -> function insert_geo_location

Below
Code: [Select]
    $sRegion = (isset($aItem['s_region']) ? $aItem['s_region'] : '');
added
Code: [Select]
$sRegionNew = explode("-", $sRegion);
$sRegionNew = $sRegionNew[0];

I changed this
Code: [Select]
    $address = sprintf('%s, %s, %s, %s', $sAddress, $sCity, $sRegion, $sCountry);
to this
Code: [Select]
    $address = sprintf('%s, %s, %s, %s', $sAddress, $sCity, $sRegionNew, $sCountry);
Now google maps is happy and I'm happy. :)
It could be used with other symbols and other fields like sCity.