Maps API v3 SVG icons
Create a marker with an SVG icon
by upsidown
HTML
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map-canvas"></div>
If nothing happens when you click on the map, please check that the example SVG image used in this example is still available (https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/aa.svg) and if not, replace it with another valid URL.
CSS
#map-canvas {
height: 400px;
}
JavaScript
var map;
var polyLine;
var polyOptions;
function initialize() {
var mapOptions = {
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(0,0)
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
google.maps.event.addListener(map, 'click', function(event) {
addPoint(event);
});
}
function addPoint(event) {
var icon = {
url: "https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/aa.svg",
anchor: new google.maps.Point(25,50),
scaledSize: new google.maps.Size(50,50)
}
var marker = new google.maps.Marker({
position: event.latLng,
map: map,
draggable: false,
icon: icon,
zIndex : -20
});
}
initialize();