gpt4 book ai didi

google-maps-api-3 - 在 Google Maps v3 Directions API 中禁用 "origin"标记的拖动

转载 作者:行者123 更新时间:2023-12-04 07:44:03 25 4
gpt4 key购买 nike

我正在尝试使用 Google Maps Directions API v3 显示 map 。我不知道如何启用“目的地”标记的拖动并禁用“原点”标记的拖动。

我知道这可以在这里设置: http://code.google.com/apis/maps/documentation/javascript/reference.html#MarkerOptions

但是,如何访问正确的标记以禁用拖动?通过 zIndex?我也试过了
response.routes[0].legs[0].start_location没有效果。有什么指点吗?

最佳答案

想通了,你们:

链接:Customer Marker Example, with some minor changes show below:

编辑(更改为粗体):

//用于禁用拖动 (origen:)(第 78 行)
startLocation.marker = createMarker(legs[i].start_location,"start",legs[i].start_address,"green", false);

//启用拖动:(目的地)(第 108 行)
endLocation.marker = createMarker(endLocation.latlng,"end",endLocation.address,"red", true);

//更新 createMarker 函数(第 175 行)
createMarker(latlng, lable, html, color, 拖动)

//更新 google.maps.Marker(第 178 行)
var marker = new google.maps.Marker({
位置:经纬度,
可拖动:拖动
map : map ,
阴影:图标阴影,
图标:getMarkerImage(颜色),
形状:图标形状,
标题:标签,
zIndex: Math.round(latlng.lat()*-100000)<<5
});

*注意:您还需要标记,已找到 herehere - 并放置在与名为“mapIcons/”的代码相同的目录中的文件夹中 *

关于google-maps-api-3 - 在 Google Maps v3 Directions API 中禁用 "origin"标记的拖动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5546649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com