Question

I'm trying to use Biostall's Google Maps v3 API to map out a series of addresses, but when I try to type in an address, the Lon Lat produced is 0, 0 every time. It only works if I specifically put in the longitude and latitude of each address. Even the entries which Biostall used on his example video and documentation don't work. I'm trying to also use the geocodeCaching feature, please help.

$this->load->library('googlemaps');

$config = array();
$config['zoom'] = 'auto';
$config['geocodeCaching'] = TRUE;
$config['region'] = 'US';
$config['sensor'] = FALSE;
$this->googlemaps->initialize($config);

$marker = array();
$marker['position'] = '37.429, -122.1519';
$marker['animation'] = 'DROP';
$this->googlemaps->add_marker($marker);

$marker = array();
$marker['position'] = '1600 Amphitheatre Parkway in Mountain View, Santa Clara County, California United States';
$marker['animation'] = 'DROP';
$this->googlemaps->add_marker($marker);

$data['map'] = $this->googlemaps->create_map();

echo print_r($data['map']['markers']);

The marker output:

Array ( [marker_0] => Array ( [latitude] => 37.429 [longitude] => -122.1519 ) [marker_1] => Array ( [latitude] => 0 [longitude] => 0 ) ) 1

This is the map produced: Map Produced

BIOSTALL's suggestion outputted this: Lat: 0 Lng: 0 Err: OVER_QUERY_LIMIT data_location: http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway+in+Mountain+View%2C+Santa+Clara+County%2C+California+United+States&sensor=false&region=US

Was it helpful?

Solution

Thanks for using my library. I have a couple of suggestions:

1) try adding ', United States' to the end of the marker position.

2) I believe there is a 'region' parameter you can set on the map. Try setting this to 'US'.

3) if it's still not working, try going into the library and find the get_lat_lon_from_address() function, then output the result of the URL request.

I hope that helps. I'm going to look at adding a debug mode soon which should help with issues like this. Let me know if any other questions though :)

Steve

OTHER TIPS

When it give OVER_QUERY_LIMIT with PHP it can mean that your IP is blocked. Especially when you try too many addresses and also when you don't wait enough between each request. Try to add a pause between each request but most likely you can only wait until the IP is free again (very annoying) or you can try a client side JavaScript. I don't know the exact reason but the reverse geocode works better client side and with JavaScript. You can also get the paid service from Google or use OpenStreetMap.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top