Wednesday 11 September 2013

Google Maps Preload XML

Google Maps Preload XML

I have a Google Maps page that I am looking to optimize as it is heavily
used. Currently, the user does the following to search:
Types an address, and clicks submit.
This page submits the address as post data to another page (map.php).
map.php is loaded, and javascript is executed to display the map.
This javascript submits a request to the webserver based on the searched
location, retrieves an xml file, and displays the results on the map.
The xml file request can take a signficant amount of time (a few seconds)
due to external factors (api). I am hoping to request this xml file before
the page has fully loaded to speed up the request. Unfortunately, this
request uses a callback that has not been defined until an external asset
has been loaded.
What is the best way for me to prefetch the xml file, and setup a callback
for a function that has not been loaded yet? Basically, I want to load the
xml file at the top of the page, and wait to call the callback function
until it has been retrieved.

No comments:

Post a Comment