I have one array with coordinates (lat, long)... This array has about 60-80 items...
In my foreach cycle there are...
...{
$lat = substr($xx[1],0,8);
$long = substr($xx[0],0,8);
?>
<script type="text/javascript">
// <![CDATA[
$(function() {
var geocoder = new google.maps.Geocoder();
function geocodePosition(pos,pos2) {
geocoder.geocode({
latLng: new google.maps.LatLng(pos,pos2)
}, function(responses) {
if (responses && responses.length > 0) {
console.log(responses[0].formatted_address);
} else {
console.log('Cannot determine address at this location.');
}
});
}
geocodePosition(<?php echo $lat ?>,<?php echo $long ?>);
});
// ]]>
</script>
<?php } ...
Geocoder geocodes at the most 5 coordinates, others come with output 'Cannot determine address at this location.'
When I take some of those, which "could not be determined", I use them manually (just 1 item = lat and long, not the whole array) it works.
So where's the problem?