Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geojson2svg

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson2svg - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

59

examples/world.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc