Dear all,
apologies in advance if my question is silly, but I am relatively new
to the Google Maps API.
What I am trying to do is to load the Google API sources from inside
another javascript method, called only if a given event (i.e. onclick
of a button) occurs. The reason is because I don't want to include the
sources and the map when the web page is loaded, but only upon request
(button click).
This is my Google API script source, as usual:

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;
   key=ABQIAAAAaotNLvAr3kII-
cK4gDGPYxQT83kIxnWUDtibwU5Ls_0buYyM5BSRBvwwjyW4yvToTy-jJ90w3tN4AA"
   type="text/javascript">
</script>

And here is how I am trying to load the script from another js method
(from inside an index.php page):

<script type="text/javascript">
var map = null;
var geocoder = null;

function loadOnEnabled()
{
  var attributesElement = document.createElement("script");
  attributesElement.setAttribute("id", "attributes");
  attributesElement.setAttribute("src", ['http://maps.google.com/maps?
file=api&amp;v=2;amp;key=ABQIAAAAaotNLvAr3kII-
cK4gDGPYxQT83kIxnWUDtibwU5Ls_0buYyM5BSRBvwwjyW4yvToTy-jJ90w3tN4AA']);
  attributesElement.setAttribute("type", "text/javascript");

  document.documentElement.firstChild.appendChild(attributesElement);
  .......................
  .......................
}

But when I click the button to enable google maps, Firefox hangs up
reading maps.google.com.

With FireBug I can see that my request generated the following error
in main.js, line2:
_mF is not defined
var m;var ba=_mF[38],ca=_mF[39],da=_mF[4...,Ta=_mF[208],Ua=_mF
[212],Va=_mF[213],Wa=

It is clear there is something wrong in the way I pass the information
to Google with the document.createElement method, but I don't know
what. I also tried some other techniques to include Google js sources
from within my method, without any luck.

Any help will be very very appreciated.

Giovanni


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to