Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to load a GMAP into a Div using Ajax. cross-domain problem??

Reply
Thread Tools

How to load a GMAP into a Div using Ajax. cross-domain problem??

 
 
Javier
Guest
Posts: n/a
 
      08-11-2009
Hi,
I have a problem trying to load a GoogleMaps map into a Div using
Ajax.
Basically I have main.php with a Div inside that is loaded with the
content of other pages like map.php.
When I try to load the content into the Div, It recognizes javascript
code, but no the javascript code of the map, so I think it's a cross-
domain problem.....
My question is: Is it possible to avoid this problem? How can I do a
very simple action like loading a Gmaps map into a Div?
Thanks for your time.
Javier.
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      08-11-2009
Javier wrote:

> I have a problem trying to load a GoogleMaps map into a Div using
> Ajax.
> Basically I have main.php with a Div inside that is loaded with the
> content of other pages like map.php.
> When I try to load the content into the Div, It recognizes javascript
> code, but no the javascript code of the map, so I think it's a cross-
> domain problem.....
> My question is: Is it possible to avoid this problem? How can I do a
> very simple action like loading a Gmaps map into a Div?


Hard without looking at the code, but at first sight I would not
suspect a cross-domain problem, since the javascripts are loaded from
Google and should always be executable (no cross-domain limitation
here).

You mention AJAX, so I suppose you are using Google's AJAX API. Could
you run the following test in a standalone page (map.html) ?

--------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Load Google map in a div</title>
<script type="text/javascript"
src="http://www.google.com/jsapi?key=YOURKEYHERE"></script>
</script>
<script type="text/javascript">
google.load('maps','2');
function loadmapdiv() {
var map = new google.maps.Map2(document.getElementById('mydiv')) ;
map.setCenter(new google.maps.LatLng(50,5),5);
}
</script>
</head>
<body>
<div id="mydiv"
style="width:300px; height:300px; background-color:silver;"></div>
<a href="#" onClick="loadmapdiv(); return false;">Load map in div</a>
</body>
</html>
--------------------------------------------------------------------

Then embed it into a PHP file (map.php), and finally embed that PHP-
file into another one (main.php).

Hope this helps,

--
Bart
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
[OFF] Convert GMap Encoded Polyline string to a set of coordinates leonardo Python 0 11-18-2012 05:00 AM
<div ... /> and <div ...></div> K Viltersten ASP .Net 4 03-31-2009 07:33 PM
NS/FF don't change div offsetWidth when div innerHTML is added toand div becomes wider mscir Javascript 3 06-26-2005 04:04 PM
Q: Div A inside Div B is larger than Div B Dwayne Madsen Javascript 1 06-01-2005 03:02 PM



Advertisments