admin管理员组文章数量:1287584
I have the problem that the label will stay black even with the labelColor property in JavaScript but i want to have it white is there any way to do so? Maybe a workaround?
for (i = 0; i < locations.length; i++) {var myLatLng = new google.maps.LatLng(locations[i][1], locations[i][2]);
marker = new google.maps.Marker({
position: myLatLng,
map: map,
label: labels[i],
labelClass: "labels", // the CSS class for the label
labelColor: '#fff',
labelInBackground: false,
icon: locations[i][4]
});
The problem is that I have custom icons that I want to use and I don't want to create some SVG first. Thanks to anyone who can help me here.
I have the problem that the label will stay black even with the labelColor property in JavaScript but i want to have it white is there any way to do so? Maybe a workaround?
for (i = 0; i < locations.length; i++) {var myLatLng = new google.maps.LatLng(locations[i][1], locations[i][2]);
marker = new google.maps.Marker({
position: myLatLng,
map: map,
label: labels[i],
labelClass: "labels", // the CSS class for the label
labelColor: '#fff',
labelInBackground: false,
icon: locations[i][4]
});
The problem is that I have custom icons that I want to use and I don't want to create some SVG first. Thanks to anyone who can help me here.
Share Improve this question edited Oct 14, 2016 at 13:26 geocodezip 161k14 gold badges226 silver badges255 bronze badges asked Oct 14, 2016 at 11:51 JohannesJohannes 1051 gold badge2 silver badges15 bronze badges2 Answers
Reset to default 11To set the label properties for a google.maps.Marker you need to use a MarkerLabel object:
var marker = new google.maps.Marker({
position: new google.maps.LatLng(37.4419, -122.1419),
map: map,
label: {
text: 'A',
color: 'white',
}
});
code snippet:
var geocoder;
var map;
function initialize() {
var map = new google.maps.Map(
document.getElementById("map_canvas"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
position: new google.maps.LatLng(37.4419, -122.1419),
map: map,
label: {
text: 'A',
color: 'white',
}
});
}
google.maps.event.addDomListener(window, "load", initialize);
html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis./maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="map_canvas"></div>
Try to check ".labels" class in CSS, maybe you should to change color in css file.
本文标签: javascriptHow to change the Markers label text colorStack Overflow
版权声明:本文标题:javascript - How to change the Markers label text color? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741308329a2371503.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论