3 Star 0 Fork 0

mirrors_ReneNyffenegger/osmtogeojson

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 6.38 KB
一键复制 编辑 原始数据 按行查看 历史
<!--
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 &rarr;</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>
&lt;script src='osmtogeojson.js'>&lt;/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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_ReneNyffenegger/osmtogeojson.git
git@gitee.com:mirrors_ReneNyffenegger/osmtogeojson.git
mirrors_ReneNyffenegger
osmtogeojson
osmtogeojson
gh-pages

搜索帮助