理论上,
this是如何禁用(内置)标记:
suppressMarkers
Type: boolean
Suppress the rendering of markers.
并this question显示如何包含代码。
但是此代码显示了我的自定义图标和Google图标(仍然是..)
var styledMap = new google.maps.StyledMapType(styles, {name: "Son Matías Beach"}); //
var mapOptions = {
zoom: 15,
scrollwheel: false,
center: new google.maps.LatLng(),
mapTypeControlOptions: {
mapTypeIds: [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 = new google.maps.LatLng(39.551741,2.736165);
var Hotel = new google.maps.Marker({
position: hotel_lat,
title:"Custom name",
icon: '../www/img/logos/map-ico.png'
});
Hotel.setMap(gmap);
var Airport = new google.maps.Marker({
position: aero_lat,
title:"Airport",
icon: '../www/img/airplane.png'
});
Airport.setMap(gmap);
gmap.mapTypes.set('map_style', styledMap);
gmap.setMapTypeId('map_style');
var mapInfoWindow = new google.maps.InfoWindow();
var mapBounds = new google.maps.LatLngBounds();
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.suppressMarkers = true; /// <-- The line
directionsDisplay.setMap(gmap);
/* ruta del hotel al aeropuerto */
route(aero_lat , hotel_lat );
gmap.setCenter(new google.maps.LatLng( hlat, hlong ));
$(window).resize(function () {
gmap.setCenter(new google.maps.LatLng( hlat, hlong ));
});
知道我做错了吗?
答案 0 :(得分:2)
这是不正确的:
1454515084: mosquitto version 1.4.7 (build date 28/12/2015 21:28:48.57) starting
1454515084: Config loaded from C:\Program Files (x86)\mosquitto/mosquitto.conf.
1454515084: Error: Unable to open acl_file "aclfile.conf".
1454515084: Error opening acl file "aclfile.conf".
DirectionsRenderer没有directionsDisplay.suppressMarkers = true; /// <-- The line
属性。您需要在构造函数中传递它:
.suppressMarkers
代码段
directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});
&#13;
var directionsDisplay, directionsService;
function initialize() {
var mapOptions = {
zoom: 15,
scrollwheel: false,
center: new 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 = new google.maps.LatLng(39.551741, 2.736165);
var Hotel = new google.maps.Marker({
position: hotel_lat,
title: "Custom name",
icon: 'http://maps.google.com/mapfiles/ms/micons/blue.png'
});
Hotel.setMap(gmap);
var Airport = new google.maps.Marker({
position: aero_lat,
title: "Airport",
icon: 'http://maps.google.com/mapfiles/ms/micons/yellow.png'
});
Airport.setMap(gmap);
var mapInfoWindow = new google.maps.InfoWindow();
var mapBounds = new google.maps.LatLngBounds();
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer({
suppressMarkers: true
});
directionsDisplay.setMap(gmap);
/* ruta del hotel al aeropuerto */
route(aero_lat, hotel_lat);
gmap.setCenter(new google.maps.LatLng(hlat, hlong));
$(window).resize(function() {
gmap.setCenter(new google.maps.LatLng(hlat, hlong));
});
}
google.maps.event.addDomListener(window, "load", initialize);
function route(origin, destination) {
directionsService.route({
origin: origin,
destination: destination,
travelMode: google.maps.TravelMode.DRIVING
}, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
&#13;
html,
body,
#gmap {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
&#13;