1
下面的代碼工作在HTML頁面,但是當我在aspx頁面中使用相同的地圖不出現。任何人都可以說出我在做什麼錯。谷歌地圖的方式點不工作在ASPX頁面同樣的事情在HTML工作
我有5站作爲航點。我想在地圖上將它們全部顯示爲推送點和旅行路線。
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript">
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(17.42354, 78.46290);
var mapOptions = {
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: chicago
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
directionsDisplay.setMap(map);
}
function calcRoute() {
var start = "17.44438,78.44251";
var end = "17.3687826,78.5246706";
var waypts = [];
waypts.push({
location: "17.44438,78.44251",
stopover: true
});
waypts.push({
location: "17.413384,78.461142",
stopover: true
});
waypts.push({
location: "17.38364,78.466964",
stopover: true
});
waypts.push({
location: "17.3836013,78.4869135",
stopover: true
});
waypts.push({
location: "17.3687826,78.5246706",
stopover: true
});
var request = {
origin: start,
destination: end,
waypoints: waypts,
optimizeWaypoints: true,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
window.onload = function() { initialize(); calcRoute(); };
</script></head>
<body>
<form id="form1" runat="server">
<div id="map-canvas"></div>
</form>
</body>
</html>
我不是一個ASP的傢伙,但可能有與報價有關的任何事情? –
我從R Square得到了解決方案。當出現帶有id map-canvas地圖的div的寬度和高度時。 – Gangadhar