无论我在哪里点击路线,我都想画一个圆圈.我找了一个关于如何使路由可点击的解决方案,但找不到任何有用的东西......下面是我的代码.当我点击路线但没有创建圆圈时,我没有收到任何错误.
directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
//direction service request here...
google.maps.event.addListener(directionsDisplay, 'click', function(event) {
var routeClick = new google.maps.Circle({
center: event.latLng, //center where you click
radius: 500,
strokeColor: "#0000FF",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#0000FF",
fillOpacity: 0.4
});
routeClick.setMap(map);
});
Run Code Online (Sandbox Code Playgroud)
更新:
基于Geocodezip脚本创建自己的方向折线的工作代码http://www.geocodezip.com/v3_directions_custom_iconsC.html和官方API示例https://developers.google.com/maps/documentation/javascript/examples/elevation-paths
// Draw the path
function drawPath(path) {
// Display a polyline of the elevation path.
var pathOptions = {
path: path,
strokeColor: '#0000CC',
strokeWeight: 5,
opacity: 0.4,
map: map
}
routePolyline = new google.maps.Polyline(pathOptions);
}
Run Code Online (Sandbox Code Playgroud)
然后在我添加的directionService请求中 …
有没有简单的方法可以使用Google Maps API v3找到折线的边界框?我正在开发一个项目,我需要在地图中添加和删除数据时更新边界.只需执行bd.extend(point)就可以轻松实现这一点,其中bd是绑定对象,point是LatLng对象.问题是,当我开始删除数据时,我希望它能够更改边界并放大.是否有任何内置函数可以执行此操作或者我是否需要为自己编写内容?