Thank you all for the replys. I updated the code to include a check to verify the last point has been coded, as suggested by Andrew. It appears to be working. I have only tested it with 6 locations, and it is working. I may include a little message that says something like 'points loading'.
I am aware that this is not the best method for a large number of points. I plan on adding some code that will cache the long and lats for future use. Currently the most this would need to handle is around 15. I plan to use the HTTP geocoder to load the position information of a site the first time a user opens the database entry. This should put off the load over time. Unfortunately I dont really know how to use JSON information, but I will eventually find out. On Jun 29, 3:29 pm, Andrew C Leach <[email protected]> wrote: > On 29 June 2010 19:31, jayjayc <[email protected]> wrote: > > > I am trying to geocode a couple of addresses passed by a url and use > > the MarkerManager to display them. > > > My map will center around the location, but will not place the > > marker(s). > > > Here is a copy with a single address as an example: > >http://sharepoint.advancedtelesystems.com/public/Downloads/MapIntegra... > > This is because the geocoder is asynchronous. > > The map is centred because the callback function does that when it > gets the point and pushes the marker on to the array. > > However, the "batch" array is added to the marker manager before the > callback function has been called, so at that point it's empty. When > the geocode result is returned, the map is centred and the marker is > pushed on to the array; but then nothing else happens to the array. > > You need to ensure that everything which needs to happen to geocoder > data happens within the callback function. > > Since you know the length of arr2, you could include a test in your > loop and only action the centring and marker-adding when you're done: > > if (i==arr2.length-1) { > gmap.setCenter(point); > mgr.addMarkers(batch, 13); > mgr.refresh(); > } > > ...but all that needs to go into the callback function, so every time > a result is processed, the code asks "Is this the last one to come > back?" and finishes the map if it is. -- You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
