function initMap() {
var uluru = {lat: 13.676442, lng: 100.638276};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: uluru
});
var marker = new google.maps.Marker({
position: uluru,
map: map,
label: {
text: "$300k",
color: "#4682B4",
fontSize: "30px",
fontWeight: "bold"
},
title: "Hello World!",
visible: true
});
}
I want to customize the label. I try to find the answers in google documentation they have only few properties to change (https://developers.google.com/maps/documentation/javascript/3.exp/reference#MarkerOptions) then I search on google the most answer is MarkerWithLabel but the problem is the link doesn't work any more http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.9/src/markerwithlabel.js" so I cannot use the library. I attach pictures from my code and what I want. Can any one help me please?
For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements. After creating this icon now we will move towards adding this marker to our Map.
The Google Maps APIs now support you in creating beautiful styled maps for your Android and iOS apps as well as your website using the same JSON style object.
You can add your own class with label.className
key:
map: map,
draggable: true,
label: {
text: value.title,
className: 'marker-label',
}
But you must know that Google adds another styles for every marker programmaticaly:
color: rgb(0, 0, 0);
font-size: 14px;
font-family: Roboto, Arial, sans-serif;
So you must override its values by yourself programmaticaly not in css according @vikashvishwakarma answer because styles have more priority as classes.
SO You can customised object by defining in html string then assign to object
let arrayElem = '<h4> Details</h4><br>Employee
ID:'+element.EmpID+'<br>Coordinates:'+element.lat+',
'+element.lng+'<br>Sequence ID:'+element.seqId+'<br>
<a>RouteID</a>:'+RouteId;
let marker = {icon:'./assets/desticontest.png',
label:{text:element.seqId.toString(),
fontSize: "20px",
fontWeight: "bold",
color:'black'},
opacity:0.8,
infoWindow:arrayElem
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With