【发布时间】:2011-12-04 07:40:23
【问题描述】:
我阅读了有关 Google API 的资料,我想实现 Google 地图针对 2 个不同点的常用 Google 行车路线。到目前为止,这是我的代码
(function() {
window.onload = function() {
// Creating a map
var options = {
zoom: 5,
center: new google.maps.LatLng(36.1834, -117.4960),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), options);
// Creating an array that will contain the points for the polyline
var route = [
new google.maps.LatLng(37.7671, -122.4206),
new google.maps.LatLng(34.0485, -118.2568)
];
// Creating the polyline object
var polyline = new google.maps.Polyline({
path: route,
strokeColor: "#ff0000",
strokeOpacity: 0.6,
strokeWeight: 5
});
// Adding the polyline to the map
polyline.setMap(map);
};
})();
两座城市之间有一条直线……
【问题讨论】:
标签: google-maps google-maps-api-3