Loading GMaps via ajax

Posted by Marco on Stack Overflow See other posts from Stack Overflow or by Marco
Published on 2010-03-25T02:18:08Z Indexed on 2010/03/25 2:23 UTC
Read the original article Hit count: 504

Filed under:
|
|

Hi to all,

I'm loading a page containing a GMaps using the ajax() method of jQuery. The HTML page i'm loading is:

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=MY_API_KEY" type="text/javascript"></script>
<script type="text/javascript">
 $(document).ready(function() {
  if (GBrowserIsCompatible()) {
   var map = new GMap2(document.getElementById("map_canvas"));
   var geocoder = new GClientGeocoder();
   geocoder.getLatLng("San Francisco, California",function(point) {
    if (point) {
     map.setCenter(point, 7);
     }
    });
   map.setUIToDefault();
  }
 });
</script>
<div id="map_canvas"></div>

After retrieving this page, I'm setting its contents to a div using the html() method. The map is not showed, while other pages containing scripts, loaded in the same way, are correctly shown. Is this a specific issue about GMaps, that doesn't allow to be loaded via an ajax request?

Thanks

© Stack Overflow or respective owner

Related posts about google-maps

Related posts about jQuery