我有一个标签的自定义标记我想将标签放在标记的中心。我尝试填充,边距和偏移仍然不会工作。我该怎么做?
var image = './stylesheet/images/map-marker/activity-marker.png';
for(var i = 0; i < data.length; i++) {
var coords = data[i].GPSCoordinates.split(',');
var position = new google.maps.LatLng(coords[0], coords[1]);
var labels = "" + (i + 1);
addMarker(position, map, labels);
}
function addMarker(location, map,label) {
var marker = new google.maps.Marker({
position: location,
map: map,
label: {
text: label,
fontSize: "12px",
color: "#e74c3c",
fontFamily: "montserrat"
},
icon: image
});
}
var image = './stylesheet/images/map-marker/activity-marker.png';
for(var i = 0; i < data.length; i++) {
var coords = data[i].GPSCoordinates.split(',');
var position = new google.maps.LatLng(coords[0], coords[1]);
var labels = "" + (i + 1);
addMarker(position, map, labels);
}
function addMarker(location, map,label) {
var marker = new google.maps.Marker({
position: location,
map: map,
icon: {
labelOrigin: new google.maps.Point(9, 9), // Set this value for position of lable on marker...
url: './stylesheet/images/map-marker/activity-marker.png'
},
label: {
text: label,
fontSize: "12px",
color: "#e74c3c",
fontFamily: "montserrat"
},
});
}
检查有效的labelOrigin
function addMarker(location, map,label) {
myIcon = {
url: './stylesheet/images/map-marker/activity-marker.png',
text: label,
fontSize: "12px",
color: "#e74c3c",
fontFamily: "montserrat"
size: new google.maps.Size(32, 38),
scaledSize: new google.maps.Size(32, 38),
labelOrigin: new google.maps.Point(9, 9),
};
var marker = new google.maps.Marker({
position: location,
map: map,
icon: myIcon,
});
}