Leaflet SVG pattern 2
Filling path with pattern on leaflet SVG-overlay doesn't work.
Copying SVG-Tree out of map makes it work in Chrome but not in Firefox.
Based on leaflet GeoJSON Example: http://leafletjs.com/examples/geojson.html
see example 1: http://jsfiddle.net/QqLLF/
HTML
<script src="http://leafletjs.com/examples/sample-geojson.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css">
<div id="map" style="width: 600px; height: 400px"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<svg class="leaflet-zoom-animated" style="transform: translate(-131px, -88px);" width="863" height="575" viewBox="-131 -88 863 575">
<defs>
<pattern height="105" width="105" y="0" x="0" patternunits="userSpaceOnUse" id="diagonalHatch">
<g style="fill:none; stroke:black; stroke-width:1">
<path d="M0 90 l15,15"></path>
<path d="M0 75 l30,30"></path>
<path d="M0 60 l45,45"></path>
<path d="M0 45 l60,60"></path>
<path d="M0 30 l75,75"></path>
<path d="M0 15 l90,90"></path>
<path d="M0 0 l105,105"></path>
<path d="M15 0 l90,90"></path>
<path d="M30 0 l75,75"></path>
<path d="M45 0 l60,60"></path>
<path d="M60 0 l45,45"></path>
<path d="M75 0 l30,30"></path>
<path d="M90 0 l15,15"></path>
</g>
</pattern>
<pattern patternunits="userSpaceOnUse" height="2" width="2" y="0" x="0" id="dotted">
<circle style="stroke: none; fill: #000" r="1" cy="0" cx="0"></circle>
</pattern>
</defs>
<g><path stroke-linejoin="round" stroke-linecap="round" fill-rule="evenodd" stroke="#000" stroke-opacity="1" stroke-width="1" fill="#ff7800" fill-opacity="0.8" d="M301,194A8,8,0,1,1,300.9,194 z" class="leaflet-clickable" style="stroke: rgb(0, 0, 0); fill: url("#dotted") none;"/></g>
<g><path stroke-linejoin="round" stroke-linecap="round" fill-rule="evenodd" stroke="#000" stroke-opacity="1" stroke-width="1" fill="#ff7800" fill-opacity="0.8" d="M309,171A8,8,0,1,1,308.9,171 z" class="leaflet-clickable" style="stroke:...
JavaScript
var map = L.map('map').setView([39.74739, -105], 13);
L.tileLayer('http://{s}.tile.cloudmade.com/{key}/22677/256/{z}/{x}/{y}.png', {
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2012 CloudMade',
key: 'BC9A493B41014CAABB98F0471D759707'
}).addTo(map);
function onEachFeature(feature, layer) {
var popupContent = "<p>I started out as a GeoJSON " +
feature.geometry.type + ", but now I'm a Leaflet vector!</p>";
if (feature.properties && feature.properties.popupContent) {
popupContent += feature.properties.popupContent;
}
layer.bindPopup(popupContent);
}
L.geoJson([bicycleRental, campus], {
style: function (feature) {
return feature.properties && feature.properties.style;
},
onEachFeature: onEachFeature,
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
radius: 8,
fillColor: "#ff7800",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8
});
}
}).addTo(map);
L.geoJson(freeBus, {
filter: function (feature, layer) {
if (feature.properties) {
// If the property "underConstruction" exists and is true, return false (don't render features under construction)
return feature.properties.underConstruction !== undefined ? !feature.properties.underConstruction : true;
}
return false;
},
onEachFeature: onEachFeature
}).addTo(map);
$(function() {
$('.leaflet-zoom-animated').prepend('<defs><pattern id="diagonalHatch" patternUnits="userSpaceOnUse" x="0" y="0" width="105" height="105"><g style="fill:none; stroke:black; stroke-width:1"><path d="M0 90 l15,15"/><path d="M0 75 l30,30"/><path d="M0 60 l45,45"/><path d="M0 45 l60,60"/><path d="M0 30 l75,75"/><path d="M0 15 l90,90"/><path d="M0 0 l105,105"/><path d="M15 0 l90,90"/><path d="M30 0 l75,75"/><path d="M45 0 l60,60"/><path...