Skip to content

Instantly share code, notes, and snippets.

@adamrosloniec
Created October 17, 2015 04:59
Show Gist options
  • Save adamrosloniec/216534181ba1ed7d627e to your computer and use it in GitHub Desktop.
Save adamrosloniec/216534181ba1ed7d627e to your computer and use it in GitHub Desktop.
google maps svg + data64 - dynamic JS generator
// 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