Thursday, May 3, 2012

[Google Maps API v2] map page with geocoding not working as expected.

The link to my site with the map page is www.jimbell.us/testmap2a.html

This code is based on Mike Williams tutorial site. The original page
is http://econym.org.uk/gmap/basic2.htm.
I wanted to use addresses instead of lon/lat to place the markers and
populate the side bar. I added 2 small functions which do the lookup
with the geocoding "getLocations" function.
I also made a few other changes to accommodate the geocoding addition.

The problem--- The resulting page shows the markers at the correct
place on the map. However, the side bar is not displayed at all. After
doing some debugging with firebug, I believe I have found the problem,
but I don't know how to fix it.

Apparently, the callback function from the geocoder getLocations
function does not hold up the execution of the following code. I added
code to the end of the javascript that checks to see if the data has
been created and it has not. So when the page is executed, you
immediately see my error message in the sidebar and then later see the
generated map. The error message in the side bar is the last line of
code in the whole page. So the page is executed quickly down to the
end and any global variables have not had data placed in them. Later
on, the callback function that was called by the getLocations to place
the markers gets executed and fills in the global variables but it is
way too late. I would like my page to work the same as the original
page in Mike's tutorials, but use addresses instead of lng/lat
coordinates.

--
You received this message because you are subscribed to the Google Groups "Google Maps API V2" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate