Geocoder Plugin - markers in incorrect position

By JeffC - September 11, 2012

Sometimes google maps gets an address/postcode location wrong. For example the position of the marker for my office is approx half a mile away from where it should be (perhaps because I am in a rural part of the country)

Google has the function to move a marker to the correct position when using google places. So now if someone puts my company name into google maps the office is shown correctly.

When using the geocoder plugin the longitude and latitude position uses googles original marker position.

Is it possible to somehow replace this with the manually positioned marker?
Jeff

Re: [Jason] Geocoder Plugin - markers in incorrect position

By JeffC - September 11, 2012

I came up with the same solution but the problem with that approach is the cms automatically replaces my manually inputted values with the geocoded ones when the page is saved.

I think, if it is ok with you guys, I would like a refund on the plugin. It is probably easier if I revert to putting the values in manually.

Im planning to buy the newsletter plugin so the money will be coming straight back to you anyway!
Jeff

Re: [Jeffncou] Geocoder Plugin - markers in incorrect position

By Jason - September 11, 2012

Hi,

You can turn off the automatic lat/long replacement in the plugin by changing this line:
$GLOBALS['GEOCODER_AUTOSET_LAT_LNG_FIELDS'] = true;

to false.

There is the same 90 day money back guarantee on plugins that we have with CMS Builder, so you can submit a refund request if the plugin isn't meeting your needs.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Geocoder Plugin - markers in incorrect position

By JeffC - September 12, 2012

Hi Jason

Changing:
$GLOBALS['GEOCODER_AUTOSET_LAT_LNG_FIELDS'] = true;

to

$GLOBALS['GEOCODER_AUTOSET_LAT_LNG_FIELDS'] = false;

Appears to stops any lat/long being generated. It is possible to auto generate the long/lat if the fields are empty but not to auto generate anything if I have already manually inputed the fields?
Jeff

Re: [Jeffncou] Geocoder Plugin - markers in incorrect position

By Jason - September 12, 2012

Hi Jeff,

Yes, this is possible if you make some custom changes to the code.

*Please note that this change has not been tested.

Try this:

First, change $GLOBALS['GEOCODER_AUTOSET_LAT_LNG_FIELDS'] back to true. Then make this code change

// Autoset form lat/lng values if we can make an address from other form values
function geocoder_autosetFormLatLngFields() {

// Skip if autoset isn't enabled or latitude and longitude aren't defined in form
if (!$GLOBALS['GEOCODER_AUTOSET_LAT_LNG_FIELDS']) { return; }
if (!array_key_exists($GLOBALS['GEOCODER_AUTOSET_LAT_FIELDNAME'], $_REQUEST)) { return; }
if (!array_key_exists($GLOBALS['GEOCODER_AUTOSET_LNG_FIELDNAME'], $_REQUEST)) { return; }

// Get address from form field combos
$address = _geocoder_getAddressFromFieldCombos( $_REQUEST );
if (!$address) { return; }

// lookup coordinates
list($lat, $lng) = geocodeAddress($address);

$record = mysql_get(@$_REQUEST['tableName'], @$_REQUEST['num']);
// Skip if record already has lat/lng values
if (@$record[ $GLOBALS['GEOCODER_AUTOSET_LAT_FIELDNAME'] ] && @$record[ $GLOBALS['GEOCODER_AUTOSET_LAT_FIELDNAME'] ]) { return; }


// override form values
if ($lat && $lng) {
$_REQUEST[ $GLOBALS['GEOCODER_AUTOSET_LAT_FIELDNAME'] ] = $lat;
$_REQUEST[ $GLOBALS['GEOCODER_AUTOSET_LNG_FIELDNAME'] ] = $lng;
}
}


This will not overwrite values if they already exist. Keep in mind that if you then change the address, the lat/lng will not be updated.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/