Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Query

Status
Not open for further replies.

daint

Technical User
Oct 4, 2000
46
0
0
GB
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
 
It's in the code listed above...

addToMap(point, ti, markerText)

Thanks

Daint
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top