Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps api 3 删除谷歌地图标记上的边界图标_Google Maps Api 3_Google Maps Markers - Fatal编程技术网

Google maps api 3 删除谷歌地图标记上的边界图标

Google maps api 3 删除谷歌地图标记上的边界图标,google-maps-api-3,google-maps-markers,Google Maps Api 3,Google Maps Markers,目前,我使用GoogleMapsAPIv3创建页面,并且有一个用户可以拖动的标记。在dragend之后,脚本将在标记之间的道路上绘制蓝线。我的问题显示在目的地上的2个标记(a标记和“B”标记) 我尝试使用fitbounds(),但仍然面临问题 <div id="current"></div> <script src="https://maps.googleapis.com/maps/api/js?key=xxx"></script> <sc

目前,我使用GoogleMapsAPIv3创建页面,并且有一个用户可以拖动的标记。在dragend之后,脚本将在标记之间的道路上绘制蓝线。我的问题显示在目的地上的2个标记(a标记和“B”标记)

我尝试使用fitbounds(),但仍然面临问题

<div id="current"></div>

<script src="https://maps.googleapis.com/maps/api/js?key=xxx"></script>
<script type="text/javascript">
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
    zoom: 14,
    center: new google.maps.LatLng(-7.760722, 110.408761),
    mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var marker = new google.maps.Marker({
    position: new google.maps.LatLng(-7.760722, 110.408761), 
    map: map,
    draggable:true
});
google.maps.event.addListener(
    marker,
    'dragend',
    function() {
        console.log(marker.position.lat());
        console.log(marker.position.lng());
        var msv = new google.maps.LatLng(-7.760722, 110.408761);
        var mgw = new google.maps.LatLng(marker.position.lat(), marker.position.lng());




        var request = {
            origin: msv,
            destination: mgw,
            travelMode: google.maps.TravelMode.DRIVING
        };
        directionsService.route(request, function (response, status) {
            if (status == google.maps.DirectionsStatus.OK) 
            {
                directionsDisplay.setDirections(response);
                directionsDisplay.setMap(map);
            }
            else
            {
                alert("Directions Request from " + start.toUrlValue(6) + " to " + end.toUrlValue(6) + " failed: " + status);
            }
        });
    }
);

var directionsService=new google.maps.directionsService();
var directionsDisplay=new google.maps.DirectionsRenderer();
变量myOptions={
缩放:14,
中心:新google.maps.LatLng(-7.760722110.408761),
mapTypeId:google.maps.mapTypeId.ROADMAP
}
var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions);
var marker=new google.maps.marker({
位置:新google.maps.LatLng(-7.760722110.408761),
地图:地图,
德拉格布尔:是的
});
google.maps.event.addListener(
标记,
“德拉根德”,
函数(){
console.log(marker.position.lat());
console.log(marker.position.lng());
var msv=new google.maps.LatLng(-7.760722110.408761);
var mgw=new google.maps.LatLng(marker.position.lat(),marker.position.lng());
var请求={
来源:msv,
目的地:mgw,
travelMode:google.maps.travelMode.DRIVING
};
路由(请求、功能(响应、状态){
if(status==google.maps.directionstatus.OK)
{
方向显示。设置方向(响应);
方向显示.setMap(地图);
}
其他的
{
警报(“从“+start.toUrlValue(6)+”到“+end.toUrlValue(6)+”的指令请求失败:“+状态”);
}
});
}
);


如何删除目标上的绑定标记(“B”标记)?我希望目标中只有一个标记

您需要删除所有标记(使用
方向渲染器上的
{suppressMarkers:true}
选项)(它们不能单独被抑制)

要显示“A”标记,请创建它:

var markerA = new google.maps.Marker({
  map: map,
  position: msv,
  label: {
    text: "A",
    color: "white"
  }
})

代码片段:

var directionservice=new google.maps.directionservice();
var directionsDisplay=新建google.maps.DirectionsRenderer({
真的吗
});
变量myOptions={
缩放:14,
中心:新google.maps.LatLng(-7.760722110.408761),
mapTypeId:google.maps.mapTypeId.ROADMAP
}
var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions);
var marker=new google.maps.marker({
位置:新google.maps.LatLng(-7.760722110.408761),
地图:地图,
德拉格布尔:是的
});
google.maps.event.addListener(
标记,
“德拉根德”,
函数(){
console.log(marker.position.lat());
console.log(marker.position.lng());
var msv=new google.maps.LatLng(-7.760722110.408761);
var mgw=new google.maps.LatLng(marker.position.lat(),marker.position.lng());
//添加“A”标记
var markerA=new google.maps.Marker({
地图:地图,
职位:msv,
标签:{
案文:“A”,
颜色:“白色”
}
})
var请求={
来源:msv,
目的地:mgw,
travelMode:google.maps.travelMode.DRIVING
};
路由(请求、功能(响应、状态){
if(status==google.maps.directionstatus.OK){
方向显示。设置方向(响应);
方向显示.setMap(地图);
}否则{
警报(“从“+start.toUrlValue(6)+”到“+end.toUrlValue(6)+”的指令请求失败:“+状态”);
}
});
}
);
html,
身体,
#地图画布{
身高:100%;
保证金:0;
填充:0;
}

var markerA = new google.maps.Marker({
  map: map,
  position: msv,
  label: {
    text: "A",
    color: "white"
  }
})