Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.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
Javascript 如何从谷歌地图中删除内置标记?_Javascript_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript 如何从谷歌地图中删除内置标记?

Javascript 如何从谷歌地图中删除内置标记?,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,理论上, 如何禁用(内置)标记: suppressMarkers Type: boolean Suppress the rendering of markers. 并演示如何包含代码 但这段代码显示了我的自定义图标和谷歌图标(仍然…) var styledMap=new google.maps.StyledMapType(样式,{name:“Son Matías Beach”})// 变量映射选项={ 缩放:15, 滚轮:错误, 中心:新的google.maps.LatLng(), map

理论上,

如何禁用(内置)标记:

suppressMarkers 
Type:  boolean
Suppress the rendering of markers.
并演示如何包含代码

但这段代码显示了我的自定义图标和谷歌图标(仍然…)

var styledMap=new google.maps.StyledMapType(样式,{name:“Son Matías Beach”})//
变量映射选项={
缩放:15,
滚轮:错误,
中心:新的google.maps.LatLng(),
mapTypeControlOptions:{
MapTypeId:[google.maps.MapTypeId.ROADMAP,'map_style']
}
}
var gmap=new google.maps.Map(document.getElementById('gmap'),mapOptions);
var hotel_lat=new google.maps.LatLng(39.514801,2.53708);
var aero_lat=新的google.maps.LatLng(39.551741,2.736165);
var Hotel=new google.maps.Marker({
职位:拉特酒店,
标题:“自定义名称”,
图标:“../www/img/logos/map ico.png”
});
赛特地图酒店(gmap);
var Airport=new google.maps.Marker({
职位:aero_lat,
标题:“机场”,
图标:“../www/img/planet.png”
});
机场地图(gmap);
gmap.mapTypes.set('map\u style',styledMap);
gmap.setMapTypeId('map_style');
var mapInfoWindow=new google.maps.InfoWindow();
var mapBounds=new google.maps.LatLngBounds();
var方向显示;
var directionsService=new google.maps.directionsService();
directionsDisplay=new google.maps.DirectionsRenderer();
directionsDisplay.suppressMarkers=true;/// 这是不正确的:

directionsDisplay.suppressMarkers = true; /// <-- The line

代码片段:

var方向显示、方向服务;
函数初始化(){
变量映射选项={
缩放:15,
滚轮:错误,
中心:新的google.maps.LatLng(),
};
var gmap=new google.maps.Map(document.getElementById('gmap'),mapOptions);
var hotel_lat=new google.maps.LatLng(39.514801,2.53708);
var aero_lat=新的google.maps.LatLng(39.551741,2.736165);
var Hotel=new google.maps.Marker({
职位:拉特酒店,
标题:“自定义名称”,
图标:'http://maps.google.com/mapfiles/ms/micons/blue.png'
});
赛特地图酒店(gmap);
var Airport=new google.maps.Marker({
职位:aero_lat,
标题:“机场”,
图标:'http://maps.google.com/mapfiles/ms/micons/yellow.png'
});
机场地图(gmap);
var mapInfoWindow=new google.maps.InfoWindow();
var mapBounds=new google.maps.LatLngBounds();
directionsService=new google.maps.directionsService();
directionsDisplay=新建google.maps.DirectionsRenderer({
真的吗
});
方向显示.setMap(gmap);
/*阿尔埃罗波托鲁塔德尔酒店*/
路线(aero_lat、hotel_lat);
gmap.setCenter(新的google.maps.LatLng(hlat,hlong));
$(窗口)。调整大小(函数(){
gmap.setCenter(新的google.maps.LatLng(hlat,hlong));
});
}
google.maps.event.addDomListener(窗口“加载”,初始化);
功能路线(起点、终点){
方向服务.路线({
来源:来源,,
目的地:目的地,
travelMode:google.maps.travelMode.DRIVING
},功能(响应、状态){
if(status==google.maps.directionstatus.OK){
方向显示。设置方向(响应);
}否则{
window.alert('由于'+状态,指示请求失败);
}
});
}
html,
身体,
#gmap{
身高:100%;
宽度:100%;
边际:0px;
填充:0px
}


不知道为什么,但必须这样传递:
directionsDisplay=new google.maps.directionsrender({suppressMarkers:true})我知道。我在评论中提到。我猜链接答案的问题是不正确的。。谢谢
directionsDisplay.suppressMarkers = true; /// <-- The line
directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});