I use Google Maps JavaScript API to display maps - https://developers.google.com/maps/documentation/javascript/
There are certain features in that API that I need that the static maps does not have.
So this page works fine as a stand alone page:
<!DOCTYPE html>
<html>
<head>
<title>Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
function initialize() {
// Set map coordinates with lat and lng
var cord = new google.maps.LatLng(28.545078,-81.377196);
// Set map options
var mapOptions = {
zoom: 15,
center: cord,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Set map
var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
// Set map marker
var marker = new google.maps.Marker({
position: cord,
map: map,
title: 'Test'
});
}
// Load Map
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"style="width:600px; height:500px"></div>
</body>
</html>
I need to get that page working inside of a jQuery Dialog Window.
I call the dialog and load the external page like this:
<script type="text/javascript">
$(document).ready(function() {
$("#cc").click(function(){
$("#detailWin").dialog({
autoOpen: false,
modal: true,
width:700,
height:600,
show: "fade",
close: "fade",
open: function ()
{
$(this).load('p2.php');
}
});
$('#detailWin').dialog("open");
});
});
</script>
So when I include the first set of code into the maps.php page it does not work. I realize that I do not want to include all the and tags on the included page. I've been trying it many different ways I cannot get the maps to load in the dialog window.
I've tried loading the maps API URL with jQuery $.getScript()
but it's not helping.
If anyone can help me figure out the best way to get this working it would be greatly appreciated because I am stuck.
Thanks!
UPDATE:
I ended up getting it to work like this (this the second page maps.php):
<script type="text/javascript">
$(document).ready(function() {
function initialize() {
// Set map coordinates with lat and lng
var cord = new google.maps.LatLng(28.545078,-81.377196);
// Set map options
var mapOptions = {
zoom: 15,
center: cord,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Set map
var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
// Set map marker
var marker = new google.maps.Marker({
position: cord,
map: map,
title: 'Test'
});
}
// Load Map
google.maps.event.addDomListener(window, 'load', initialize);
initialize();
});
</script>
<div>
<div id="map-canvas"style="width:600px; height:500px"></div>
</div>