Created
October 17, 2015 04:59
-
-
Save adamrosloniec/216534181ba1ed7d627e to your computer and use it in GitHub Desktop.
google maps svg + data64 - dynamic JS generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// google maps svg + data64 - dynamic JS generator | |
var map = new google.maps.Map(document.getElementById('map'), { | |
zoom: 11, | |
center: new google.maps.LatLng(-10.22, 100.44), | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}); | |
var template = [ | |
'<?xml version="1.0"?>', | |
'<svg width="30px" height="30px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">', | |
'<circle stroke="#000" fill="{{ color }}" cx="50" cy="50" r="35"/>', | |
'</svg>' | |
].join('\n'); | |
var svg = template.replace('{{ color }}', '#ff1100'); | |
var docMarker = new google.maps.Marker({ | |
position: new google.maps.LatLng(-10.22, 100.44), | |
map: map, | |
title: 'Title of Marker', | |
icon: { url: 'data:image/svg+xml;charset=UTF-8;base64,' + btoa(svg) } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment