-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 40ad575
Showing
9 changed files
with
402 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Copyright 2012, John Firebaugh | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation and/or | ||
other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS | ||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
Portions derived from OpenLayers, Copyright 2005-2012 OpenLayers Contributors. | ||
All rights reserved. See authors.txt for full list. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation and/or | ||
other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY OPENLAYERS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS | ||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
The views and conclusions contained in the software and documentation are those | ||
of the authors and should not be interpreted as representing official policies, | ||
either expressed or implied, of OpenLayers Contributors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
leaflet-osm is a [Leaflet](http://leaflet.cloudmade.com/) plugin for rendering | ||
vector data from openstreetmap.org. | ||
|
||
For example, the openstreetmap.org website could use it to highlight a particular | ||
[way](http://www.openstreetmap.org/?way=52477381) or [node](http://www.openstreetmap.org/?node=164979149) | ||
on the base map. | ||
|
||
## Usage Example | ||
|
||
``` | ||
$.ajax({ | ||
url: "http://www.openstreetmap.org/api/0.6/node/164979149", | ||
// or "http://www.openstreetmap.org/api/0.6/way/52477381/full" | ||
dataType: "xml", | ||
success: function (xml) { | ||
var layer = new L.OSM(xml).addTo(map); | ||
map.fitBounds(layer.getBounds()); | ||
} | ||
}); | ||
``` | ||
|
||
Well, this would work if openstreetmap.org's API supported CORS. Right now it'll | ||
only work if your code is running on openstreetmap.org itself. | ||
|
||
## Contributing | ||
|
||
leaflet-osm is tested with node.js using [mocha](http://visionmedia.github.com/mocha/) and [chai](http://chaijs.com/): | ||
|
||
``` | ||
$ npm install -g mocha | ||
$ npm install | ||
$ mocha | ||
``` | ||
|
||
## License | ||
|
||
Copyright 2012 John Firebaugh | ||
|
||
BSD License (see the BSD-LICENSE file) | ||
|
||
Portions derived from [OpenLayers](https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Format/OSM.js). | ||
See BSD-LICENSE for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
L.OSM = L.FeatureGroup.extend({ | ||
options: { | ||
areaTags: ['area', 'building', 'leisure', 'tourism', 'ruins', 'historic', 'landuse', 'military', 'natural', 'sport'], | ||
uninterestingTags: ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by'] | ||
}, | ||
|
||
initialize: function (xml, options) { | ||
L.Util.setOptions(this, options); | ||
|
||
L.FeatureGroup.prototype.initialize.call(this); | ||
|
||
if (xml) { | ||
this.addData(xml); | ||
} | ||
}, | ||
|
||
addData: function (xml) { | ||
var nodes = L.OSM.getNodes(xml), | ||
ways = L.OSM.getWays(xml); | ||
|
||
for (var i = 0; i < ways.length; i++) { | ||
var way = ways[i], | ||
latLngs = new Array(way.nodes.length); | ||
|
||
for (var j = 0; j < way.nodes.length; j++) { | ||
latLngs[j] = nodes[way.nodes[j]].latLng; | ||
} | ||
|
||
if (this.isWayArea(way)) { | ||
latLngs.pop(); // Remove last == first. | ||
L.polygon(latLngs).addTo(this); | ||
} else { | ||
L.polyline(latLngs).addTo(this); | ||
} | ||
} | ||
|
||
for (var node_id in nodes) { | ||
var node = nodes[node_id]; | ||
if (this.interestingNode(node)) { | ||
L.circleMarker(node.latLng, {radius: 6}).addTo(this); | ||
} | ||
} | ||
}, | ||
|
||
isWayArea: function (way) { | ||
if (way.nodes[0] != way.nodes[way.nodes.length - 1]) { | ||
return false; | ||
} | ||
|
||
for (var key in way.tags) { | ||
if (~this.options.areaTags.indexOf(key)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
}, | ||
|
||
interestingNode: function (node) { | ||
for (var key in node.tags) { | ||
if (!~this.options.uninterestingTags.indexOf(key)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
}); | ||
|
||
L.Util.extend(L.OSM, { | ||
getNodes: function (xml) { | ||
var result = {}; | ||
|
||
var node_list = xml.getElementsByTagName("node"); | ||
for (var i = 0; i < node_list.length; i++) { | ||
var node = node_list[i]; | ||
result[node.getAttribute("id")] = { | ||
latLng: L.latLng(node.getAttribute("lat"), | ||
node.getAttribute("lon"), | ||
true), | ||
tags: this.getTags(node) | ||
}; | ||
} | ||
|
||
return result; | ||
}, | ||
|
||
getWays: function (xml) { | ||
var result = []; | ||
|
||
var way_list = xml.getElementsByTagName("way"); | ||
for (var i = 0; i < way_list.length; i++) { | ||
var way = way_list[i], | ||
node_list = way.getElementsByTagName("nd"); | ||
|
||
var way_object = { | ||
id: way.getAttribute("id"), | ||
nodes: new Array(node_list.length), | ||
tags: this.getTags(way) | ||
}; | ||
|
||
for (var j = 0; j < node_list.length; j++) { | ||
way_object.nodes[j] = node_list[j].getAttribute("ref"); | ||
} | ||
|
||
result.push(way_object); | ||
} | ||
|
||
return result; | ||
}, | ||
|
||
getTags: function (xml) { | ||
var result = {}; | ||
|
||
var tags = xml.getElementsByTagName("tag"); | ||
for (var j = 0; j < tags.length; j++) { | ||
result[tags[j].getAttribute("k")] = tags[j].getAttribute("v"); | ||
} | ||
|
||
return result; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"author": "John Firebaugh <john.firebaugh@gmail.com>", | ||
"name": "leaflet-osm", | ||
"description": "OpenStreetMap plugin for Leaflet", | ||
"version": "0.0.0", | ||
"repository": { | ||
"url": "" | ||
}, | ||
"main": "./leaflet-osm.js", | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"engines": { | ||
"node": "~0.8.4" | ||
}, | ||
"dependencies": { | ||
"leaflet": "git://github.com/jfirebaugh/Leaflet.git" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"chai": "*", | ||
"jsdom": "*" | ||
}, | ||
"optionalDependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"> | ||
<node id="1911003422" version="1" changeset="13078014" lat="44.6639106" lon="-73.0183662" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:23Z"/> | ||
<node id="1911003505" version="1" changeset="13078014" lat="44.663365" lon="-73.0184144" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:25Z"/> | ||
<node id="1911003534" version="1" changeset="13078014" lat="44.6631742" lon="-73.0151529" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:26Z"/> | ||
<node id="1911003542" version="1" changeset="13078014" lat="44.6631857" lon="-73.0149866" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:26Z"/> | ||
<node id="1911003434" version="1" changeset="13078014" lat="44.6632593" lon="-73.0149372" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:24Z"/> | ||
<node id="1911003725" version="1" changeset="13078014" lat="44.6633765" lon="-73.0149061" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:29Z"/> | ||
<node id="1911003400" version="1" changeset="13078014" lat="44.6641548" lon="-73.0149544" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:23Z"/> | ||
<node id="1911003459" version="1" changeset="13078014" lat="44.6642311" lon="-73.0152709" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:24Z"/> | ||
<node id="1911003483" version="1" changeset="13078014" lat="44.6640861" lon="-73.0163599" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:25Z"/> | ||
<node id="1911003477" version="1" changeset="13078014" lat="44.6639881" lon="-73.0163749" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:24Z"/> | ||
<node id="1911003428" version="1" changeset="13078014" lat="44.6639144" lon="-73.0164457" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:24Z"/> | ||
<node id="1911003481" version="1" changeset="13078014" lat="44.6640251" lon="-73.0181462" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:25Z"/> | ||
<node id="1911003614" version="1" changeset="13078014" lat="44.6640251" lon="-73.018275" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:27Z"/> | ||
<node id="1911003629" version="1" changeset="13078014" lat="44.6639945" lon="-73.0183447" user="jfire" uid="67236" visible="true" timestamp="2012-09-12T04:59:27Z"/> | ||
<way id="180655479" visible="true" timestamp="2012-09-12T04:59:32Z" version="1" changeset="13078014" user="jfire" uid="67236"> | ||
<nd ref="1911003422"/> | ||
<nd ref="1911003505"/> | ||
<nd ref="1911003534"/> | ||
<nd ref="1911003542"/> | ||
<nd ref="1911003434"/> | ||
<nd ref="1911003725"/> | ||
<nd ref="1911003400"/> | ||
<nd ref="1911003459"/> | ||
<nd ref="1911003483"/> | ||
<nd ref="1911003477"/> | ||
<nd ref="1911003428"/> | ||
<nd ref="1911003481"/> | ||
<nd ref="1911003614"/> | ||
<nd ref="1911003629"/> | ||
<nd ref="1911003422"/> | ||
<tag k="leisure" v="pitch"/> | ||
</way> | ||
</osm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"> | ||
<node id="356552551" version="1" changeset="747176" lat="44.6636172" lon="-73.0132525" user="iandees" uid="4732" visible="true" timestamp="2009-03-07T03:26:33Z"> | ||
<tag k="ele" v="114"/> | ||
<tag k="gnis:edited" v="05/27/2008"/> | ||
<tag k="gnis:state_id" v="50"/> | ||
<tag k="gnis:feature_id" v="1456383"/> | ||
<tag k="amenity" v="school"/> | ||
<tag k="name" v="Bellows Free Academy"/> | ||
<tag k="gnis:county_id" v="011"/> | ||
<tag k="gnis:created" v="10/29/1980"/> | ||
</node> | ||
</osm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"> | ||
<node id="204595896" version="2" changeset="2817006" lat="44.665883" lon="-72.923053" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595901" version="2" changeset="2817006" lat="44.66597" lon="-72.922201" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595904" version="2" changeset="2817006" lat="44.665989" lon="-72.921986" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595911" version="2" changeset="3138486" lat="44.666015" lon="-72.921474" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-11-17T05:45:06Z"/> | ||
<node id="204595915" version="2" changeset="2817006" lat="44.666015" lon="-72.921254" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595919" version="2" changeset="2817006" lat="44.666007" lon="-72.921033" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204587613" version="2" changeset="2817006" lat="44.665983" lon="-72.920587" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:01:27Z"/> | ||
<node id="204595923" version="2" changeset="2817006" lat="44.665938" lon="-72.920089" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595927" version="2" changeset="2817006" lat="44.665901" lon="-72.919727" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595932" version="2" changeset="3138486" lat="44.665837" lon="-72.919284" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-11-17T05:45:06Z"/> | ||
<node id="204595935" version="2" changeset="2817006" lat="44.665821" lon="-72.91914" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595939" version="2" changeset="2817006" lat="44.66581" lon="-72.918999" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595943" version="2" changeset="2817006" lat="44.665814" lon="-72.918855" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595947" version="2" changeset="3346870" lat="44.665823" lon="-72.918783" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-12-11T06:32:30Z"/> | ||
<node id="204595950" version="2" changeset="2817006" lat="44.665839" lon="-72.91871" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595953" version="2" changeset="2817006" lat="44.66587" lon="-72.918641" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595955" version="2" changeset="2817006" lat="44.665923" lon="-72.918586" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595957" version="2" changeset="2817006" lat="44.665985" lon="-72.918559" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<node id="204595961" version="2" changeset="3138486" lat="44.666193" lon="-72.918523" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-11-17T05:45:06Z"/> | ||
<node id="204595963" version="2" changeset="2817006" lat="44.666342" lon="-72.918513" user="woodpeck_fixbot" uid="147510" visible="true" timestamp="2009-10-11T18:03:23Z"/> | ||
<way id="19698713" visible="true" timestamp="2008-01-03T05:24:43Z" version="1" changeset="522559" user="DaveHansenTiger" uid="7168"> | ||
<nd ref="204595896"/> | ||
<nd ref="204595901"/> | ||
<nd ref="204595904"/> | ||
<nd ref="204595911"/> | ||
<nd ref="204595915"/> | ||
<nd ref="204595919"/> | ||
<nd ref="204587613"/> | ||
<nd ref="204595923"/> | ||
<nd ref="204595927"/> | ||
<nd ref="204595932"/> | ||
<nd ref="204595935"/> | ||
<nd ref="204595939"/> | ||
<nd ref="204595943"/> | ||
<nd ref="204595947"/> | ||
<nd ref="204595950"/> | ||
<nd ref="204595953"/> | ||
<nd ref="204595955"/> | ||
<nd ref="204595957"/> | ||
<nd ref="204595961"/> | ||
<nd ref="204595963"/> | ||
<tag k="highway" v="residential"/> | ||
<tag k="name" v="Oustinoff Rd"/> | ||
<tag k="tiger:cfcc" v="A41"/> | ||
<tag k="tiger:county" v="Franklin, VT"/> | ||
<tag k="tiger:name_base" v="Oustinoff"/> | ||
<tag k="tiger:name_type" v="Rd"/> | ||
<tag k="tiger:reviewed" v="no"/> | ||
<tag k="tiger:separated" v="no"/> | ||
<tag k="tiger:source" v="tiger_import_dch_v0.6_20070830"/> | ||
<tag k="tiger:tlid" v="136533324:136533325"/> | ||
<tag k="tiger:upload_uuid" v="bulk_upload.pl-62def9fe-abee-42f3-ac1f-9d9f4b4ee78b"/> | ||
<tag k="tiger:zip_left" v="05444"/> | ||
<tag k="tiger:zip_right" v="05444"/> | ||
</way> | ||
</osm> |
Oops, something went wrong.