geojson2svg
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -1,30 +0,29 @@ | ||
var dataURLPoly = './data/countries.geo.json'; | ||
//var dataURL = './data/CAN.geo.json'; | ||
var dataURLPoint = './data/capitals.json'; | ||
getjson(dataURLPoint,drawGeoJSON); | ||
getjson(dataURLPoly,drawGeoJSON); | ||
function drawGeoJSON(resp) { | ||
var geojson = JSON.parse(resp); | ||
var svgMap = document.getElementById('map'); | ||
var convertor = geojson2svg({width:800,height:800}); | ||
//var attributes = {style:"stroke:#006600; fill: #00cc00"}; | ||
var attributes = {style:"stroke:#006600; fill: none;stroke-width:1px;"}; | ||
var svgElements = convertor.convert(geojson,{attributes:attributes,output:'svg',explode:false}); | ||
var parser = new DOMParser(); | ||
svgElements.forEach(function(svgStr) { | ||
var el = parser.parseFromString(svgStr, "image/svg+xml"); | ||
//var svg = el.firstChild; | ||
var svg = parseSVG(svgStr); | ||
svgMap.appendChild(svg); | ||
}); | ||
} | ||
//parseSVG from http://stackoverflow.com/questions/3642035/jquerys-append-not-working-with-svg-element | ||
function parseSVG(s) { | ||
var div= document.createElementNS('http://www.w3.org/1999/xhtml', 'div'); | ||
div.innerHTML= '<svg xmlns="http://www.w3.org/2000/svg">'+s+'</svg>'; | ||
var frag= document.createDocumentFragment(); | ||
while (div.firstChild.firstChild) | ||
frag.appendChild(div.firstChild.firstChild); | ||
return frag; | ||
} | ||
var dataURLPoly = './data/countries.geo.json'; | ||
// countries data taken from https://github.com/johan/world.geo.json | ||
getjson(dataURLPoly,drawGeoJSON); | ||
//var dataURLPoint = './data/capitals.json'; | ||
//getjson(dataURLPoint,drawGeoJSON); | ||
function drawGeoJSON(resp) { | ||
var geojson = JSON.parse(resp); | ||
var svgMap = document.getElementById('map'); | ||
var convertor = geojson2svg({width:800,height:800}); | ||
var attributes = { | ||
'style': 'stroke:#006600; fill: #F0F8FF;stroke-width:0.5px;', | ||
'vector-effect':'non-scaling-stroke'}; | ||
var svgElements = convertor.convert(geojson,{attributes:attributes,output:'svg',explode:false}); | ||
var parser = new DOMParser(); | ||
svgElements.forEach(function(svgStr) { | ||
var svg = parseSVG(svgStr); | ||
svgMap.appendChild(svg); | ||
}); | ||
} | ||
//parseSVG from http://stackoverflow.com/questions/3642035/jquerys-append-not-working-with-svg-element | ||
function parseSVG(s) { | ||
var div= document.createElementNS('http://www.w3.org/1999/xhtml', 'div'); | ||
div.innerHTML= '<svg xmlns="http://www.w3.org/2000/svg">'+s+'</svg>'; | ||
var frag= document.createDocumentFragment(); | ||
while (div.firstChild.firstChild) | ||
frag.appendChild(div.firstChild.firstChild); | ||
return frag; | ||
} |
{ | ||
"name": "geojson2svg", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Converts geojson to svg/path string given svg viewport size and maps extent.", | ||
@@ -5,0 +5,0 @@ "main": "src/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1459649
6650