Polymaps.org & KML / Plotting lines in GeoJSON
Has anyone had a play with the Polymaps.org KML parser? To me it seems the example doesn't even work.
I have an existing KML file which is being generated from a very simple database - I have a placemark name, and a lat/long in decimal notation for said place开发者_运维技巧mark. I have hundreds of these, that form a route - What I want to do is very simple, and Polymaps is perfect, but there are limited GeoJSON examples, and even more limited Polymaps examples.
Are there any GeoJSON experts that could lend a hand? I basically want to create a GeoJSON stream which takes my placemark name, lat & long and creates a line to form a route.
Haven't tried the KML parser, but here's an example of working with Geoserver geoJSON
<style>
.layer path { fill: none; stroke: blue; stroke-width: 2;}
.layer circle { fill: lightcoral; fill-opacity: .5; stroke: brown; }
</style>
<script>
function myCallback(data) {
po = org.polymaps;
map = po.map()
.container(document.getElementById("map").appendChild(po.svg("svg")))
.center({
lat:(data.bbox[1] + (data.bbox[3]-data.bbox[1])/2),
lon:(data.bbox[0] + (data.bbox[2]-data.bbox[0])/2)
})
.zoom(15)
.add(po.interact());
// points
map.add(po.geoJson().features( data.features ));
// make path
var paths=[];
for (var i=0;i<data.features.length;i++)
paths.push(data.features[i].geometry.coordinates);
map.add(po.geoJson()
.features([{"geometry":{"coordinates":paths, "type": "LineString"}}]));
}
var client = document.createElement("script");
client.src = 'http://localhost:8082/geoserver/ows?'+
'service=WFS&version=1.0.0&request=GetFeature'+
'&typeName=tiger:poi&maxFeatures=50'+
'&outputFormat=json&format_options=callback:myCallback';
document.body.appendChild(client);
</script>
精彩评论