我的用户最近告诉我,默认页面的加载速度比以前慢得多。我认为这是因为地图在页面加载时立即加载。有没有办法将它延迟到单击单击此处按钮?
根据迄今为止从答案中收到的建议,我决定从外部 URL 调用地图。但加载页面上的 Javascript 未执行。我可以解决这个问题吗?
谢谢!
这就是我调用外部页面的方式。
$(function() {
// if the function argument is given to overlay,
// it is assumed to be the onBeforeLoad event listener
$("a[rel]").overlay({
mask: 'darkred',
effect: 'apple',
onBeforeLoad: function() {
// grab wrapper element inside content
var wrap = this.getOverlay().find(".contentWrap");
// load the page specified in the trigger
wrap.load(this.getTrigger().attr("href"));
}
});
});
<!-- external page is given in the href attribute (as it should be) -->
<a href="default.cs.asp?Process=ViewCheckinMap" rel="#overlay" style="text-decoration:none">
<!-- remember that you can use any element inside the trigger -->
<button type="button">Show external page in overlay</button>
</a>
这是没有执行的。
<script>
function initialize() {
var data = <%=Data%>;
var center = new google.maps.LatLng(48.404840395764175, 2.6845264434814453);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var markers = [];
for (var i = 0; i < data.users.length; i++) {
var location = data.users[i];
var latLng = new google.maps.LatLng(location.latitude,
location.longitude);
var marker = new google.maps.Marker({
position: latLng
});
markers.push(marker);
}
var markerCluster = new MarkerClusterer(map, markers);
}
google.maps.event.addDomListener(window, 'click', initialize);
</script>