我正在尝试load (append) a php script by name child.php to a parent.php file via ajax
致电。
$.get("child.php", function(data) {
$("div-for-child").append(data);
}
child.php包含加载谷歌地图的脚本。但这不会发生。
<script>
window.onload = function(){
initialise(cordinates, id, paramas);
};
</script>
initialise
函数是:
function initialise() {
var myLatlng = new google.maps.LatLng(cordinates);
var mapOptions = {
zoom: 8,
minZoom: 6,
maxZoom: 17,
zoomControl:true,
zoomControlOptions: {
style:google.maps.ZoomControlStyle.DEFAULT
},
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl:false, // Set to false to disable
mapTypeControl:false, // Disable Map/Satellite switch
scaleControl:false, // Set to false to hide scale
streetViewControl:false, // Set to disable to hide street view
overviewMapControl:false, // Set to false to remove overview control
rotateControl:false // Set to false to disable rotate control
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var image = new google.maps.MarkerImage("image/path", null, null, null, new google.maps.Size(40,52));
var marker = new google.maps.Marker({ // Set the marker
position: myLatlng, // Position marker to coordinates
icon:image, //use our image as the marker
map: map, // assign the market to our map variable
title: 'Click to visit our company on Google Places' });
var infowindow = new google.maps.InfoWindow({ // Create a new InfoWindow
content:"<h3>Snowdown Summit Cafe</h3><p>Railway Drive-through available.</p>" // HTML contents of the InfoWindow
});
google.maps.event.addListener(marker, 'click', function() { // Add a Click Listener to our marker
infowindow.open(map,marker); // Open our InfoWindow
});
}
google.maps.event.addDomListener(window, 'load', initialise); // Execute our 'initialise' function once the page has loaded.
The initalise function is an external script.
所以最后的图片。每当我load or append child.php to parent.php via ajax
。 child.php
中的地图未加载。我只是得到一个没有内容的空div
。
头部是:
<head>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"> </script>
<script src="js/map.js"> // Initialise function is here in map.js file
</head>