问题
I'm looking how to add specific markers to my gmap.
This is the code:
LatLng coord1 = new LatLng (y, x);
advancedModel.addOverlay(new Marker(coord1, "test", "orange.png", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
I want to add my specific marker which is in /resources/images not this one http://maps.google.com/mapfiles/ms/micons/blue-dot.png
Can you help?
回答1:
You can add custom markers in Google Maps and you can also change the marker icon, depending on the type of feature the marker's being added to. Each point of interest in the list of campus features has a type attribute.
Below code is a sample code snippet how to add custom markers:
var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
var icons = {
parking: {
icon: iconBase + 'parking_lot_maps.png'
},
library: {
icon: iconBase + 'library_maps.png'
},
info: {
icon: iconBase + 'info-i_maps.png'
}
};
function addMarker(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
map: map
});
}
回答2:
You can do something like this:
Marker newMarker = new Marker(new LatLng(latitude, longitude));
newMarker.setIcon("resources/media/marker-blue-dot.png");
simpleModel.addOverlay(newMarker);
来源:https://stackoverflow.com/questions/36690226/how-to-add-custom-markers-gmap