Hello,
I'm slowly learning Javascript, but have an issue when using the Google Maps and Search API.
Below is a snippet of code...
var t0 = new usePointFromPostcode('E3 2NN',0,'Test 1')
var t1 = new usePointFromPostcode('E1 2NN',1,'Test 2')
var t2 = new usePointFromPostcode('E2 2NN',2,'Test 3')
var t3 = new usePointFromPostcode('E5 2NN',3,'Test 4')
var t4 = new usePointFromPostcode('E7 2NN',4,'Test 5')
function usePointFromPostcode(postcode, ti, markerText)
{
localSearch.setSearchCompleteCallback(null,function() {
if (localSearch.results[0])
{
var resultLat = localSearch.results[0].lat;
var resultLng = localSearch.results[0].lng;
var point = new GLatLng(resultLat,resultLng);
addToMap(point, ti, markerText)
}
});
localSearch.execute(postcode + ", UK");
}
For some reason, whenever 'addToMap' is called, the same values are sent to the function each time, 'E7 2NN',4,'Test 5'
I'm guessing this is related to the pause in retrieving results from google, but how do I overcome this?
Thanks
Daint
I'm slowly learning Javascript, but have an issue when using the Google Maps and Search API.
Below is a snippet of code...
var t0 = new usePointFromPostcode('E3 2NN',0,'Test 1')
var t1 = new usePointFromPostcode('E1 2NN',1,'Test 2')
var t2 = new usePointFromPostcode('E2 2NN',2,'Test 3')
var t3 = new usePointFromPostcode('E5 2NN',3,'Test 4')
var t4 = new usePointFromPostcode('E7 2NN',4,'Test 5')
function usePointFromPostcode(postcode, ti, markerText)
{
localSearch.setSearchCompleteCallback(null,function() {
if (localSearch.results[0])
{
var resultLat = localSearch.results[0].lat;
var resultLng = localSearch.results[0].lng;
var point = new GLatLng(resultLat,resultLng);
addToMap(point, ti, markerText)
}
});
localSearch.execute(postcode + ", UK");
}
For some reason, whenever 'addToMap' is called, the same values are sent to the function each time, 'E7 2NN',4,'Test 5'
I'm guessing this is related to the pause in retrieving results from google, but how do I overcome this?
Thanks
Daint