Skip to content

Instantly share code, notes, and snippets.

@chibaye
Created May 1, 2019 19:30
Show Gist options
  • Save chibaye/f9998204cb929f785273a81cd1d01052 to your computer and use it in GitHub Desktop.
Save chibaye/f9998204cb929f785273a81cd1d01052 to your computer and use it in GitHub Desktop.
SVG Marker for Google Maps API Example
<div id="map" style="width: 100%; height: 500px"></div>
window.addEventListener('load', function() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
center: new google.maps.LatLng(30.267074, -97.743473)
});
// See Github for class https://github.com/defvayne23/SVGMarker
var marker = new SVGMarker({
map: map,
position: new google.maps.LatLng(30.282788, -97.731457),
icon: {
anchor: new google.maps.Point(30, 30.26),
size: new google.maps.Size(60,30.26),
url: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/134893/pin-red.svg'
}
})
});
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/134893/SVGMarker.js"></script>

SVG Marker for Google Maps API Example

Google Maps JavaScript API overlay class to easily add markers with an SVG image as the icon.

A Pen by John Hoover on CodePen.

License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment