代码拉取完成,页面将自动刷新
<!--
demo page / introduction for osmtogeojson
https://tyrasd.github.io/osmtogeojson
https://github.com/tyrasd/osmtogeojson
this page is based on https://github.com/aaronlidman/osm-and-geojson (c)Aaron Lidman, WTFPL
-->
<html>
<head>
<title>osmtogeojson</title>
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="osmtogeojson.js"></script>
<script type="text/javascript">
function toGeo(e) {
e.preventDefault();
var data = document.getElementById('osmxml').value || "<osm></osm>",
geojson;
try {
data = $.parseXML(data);
} catch(e) {
data = JSON.parse(data);
}
geojson = osmtogeojson(data);
document.getElementById('geojson').value = JSON.stringify(geojson, null, 4);
console.log(geojson);
}
$(function() {
$("#toGeo").click(toGeo);
});
</script>
<style type="text/css">
body {
font-size: 18px;
background: white;
font-family: "Helvetica Neue", Helvetica, sans-serif;
width: 960px;
margin: 50px auto;
color: #222;
line-height: 1.7em
}
a { color: black; }
li {
line-height: 1.7em;
text-align: left;
list-style: none;
}
textarea, input { outline: none; }
#left {
width: 49%;
float: left;
text-align: center;
}
#osmxml, #geojson {
width: 100%;
background: white;
border: 1px solid #ccc;
height: 320px;
overflow: auto;
margin-bottom: 20px;
}
#right {
width: 49%;
float: right;
text-align: center;
}
.button {
display: inline-block;
text-shadow: 0px 0px 1px black;
border-radius: 3px;
color: white;
background: #A33;
padding: 10px 15px;
font-weight: bold;
text-decoration: none;
}
.button:hover {
background: #833;
}
.button:active {
box-shadow: inset 0 0 10px rgba(0,0,0,0.75);
}
textarea {
font-size: 13px;
line-height: 1.5em;
padding: 7px 10px;
}
#top {
font-size: 22px;
text-align: center;
margin-bottom: 25px;
}
#name {
font-size: 44px;
letter-spacing: -1px;
font-weight: bold;
margin-right: 5px;
}
#example {
clear: both;
width: 100%;
height: 500px;
text-align: center;
}
#about {
width: 720px;
margin: 0 auto;
}
#download {
margin: 50px auto 0 auto;
text-align: center;
}
#dl {
background: #569834;
padding: 7px 10px;
border-radius: 3px;
color: white;
font-weight: bold;
font-size: 32px;
}
.disc { list-style: disc; }
</style>
</head>
<body>
<a href="https://github.com/tyrasd/osmtogeojson"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
<div id="top">
<span id="name">osmtogeojson</span> converts OSM data to GeoJSON.
</div>
<div id="example">
<div id="left">
<h3>OSM data</h3>
<textarea id="osmxml" contenteditable="true"></textarea>
</div>
<div id="right">
<h3>GeoJSON</h3>
<textarea id="geojson" contenteditable="true"></textarea>
</div>
<a class="button" href="" id="toGeo">convert to GeoJSON →</a>
</div>
<div id="about">
<p>osmtogeojson is a Javascript module for converting OSM data (OSM XML or Overpass JSON) to GeoJSON. It works in the browser, nodejs and can also be used as a command line tool. This OSM conversion code was written for and is maintained by the <a href="https://github.com/tyrasd/overpass-turbo">overpass-turbo</a> project.</p>
<span style="font-weight: bold;">Usage: </span>
<ul>
<li>In the browser:
<ul>
<li><code>
<script src='osmtogeojson.js'></script>
</code></li>
<li><code>
osmtogeojson(osm_data);
</code></li>
</ul>
</li>
<li>As a nodejs library:
<ul>
<li><code>
$ npm install osmtogeojson
</code></li>
<li><code>
var osmtogeojson = require('osmtogeojson');<br>
osmtogeojson(xml_data);
</code></li>
</ul>
</li>
<li>As a command line tool:
<ul>
<li><code>
$ npm install -g osmtogeojson
</code></li>
<li><code>
$ osmtogeojson file.osm > file.geojson
</code></li>
</ul>
</li>
</ul>
Read more about the API in the official <a href="https://github.com/tyrasd/osmtogeojson#usage">documentation</a>.
<div id="download">
<p><a class="button" href="https://github.com/tyrasd/osmtogeojson/raw/gh-pages/osmtogeojson.js">download osmtogeojson.js</a><br/><br/>
github: <a href="https://github.com/tyrasd/osmtogeojson">tyrasd/osmtogeojson</a><br/>
npm: <a href="https://npmjs.org/package/osmtogeojson">osmtogeojson</a><br/>
license: <a href="https://github.com/tyrasd/osmtogeojson/blob/gh-pages/LICENSE">MIT</a><br/>
</p>
</div>
</div>
</table>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。