开发者

SimpleGeo Polymaps total noob LineString displaying as polygons question?

开发者 https://www.devze.com 2023-03-24 06:55 出处:网络
So I\'m trying out polymaps as a beginner, adapting the midnight commander example: var po = org.polymaps;

So I'm trying out polymaps as a beginner, adapting the midnight commander example:

var po = org.polymaps;

var map = po.map()
    .container(document.getElementById("map").appendChild(po.svg("svg")))
    .add(po.interact())
    .add(po.hash());

map.add(po.image()
    .url(po.url("http://{S}tile.cloudmade开发者_如何学运维.com"
    + "/985d631542924aaa8718b9864529ae8c" // http://cloudmade.com/register
    + "/37326/256/{Z}/{X}/{Y}.png")
    .hosts(["a.", "b.", "c.", ""])));

map.add(po.compass()
.pan("none"));

to which I am loading some roads locally in geoJson format:

map.add(po.geoJson().url("mylines.geojson")); 

GeoJson sample:

{"type": "FeatureCollection", "features": [{"geometry": {"type": "LineString", "coordinates": [[-4.240532511128865, 55.891926951654455], [-4.238934645983739, 55.891956028400834]]}, "type": "Feature", "id": 6718, "properties": {"IDENTIFIER": "2602840669377", "CODE": 6140, "NAME": ""}}]}

Now mylines.geojson displays but it isn't displaying as a line but as polygons.

My question is, what do I need to do to get Polymaps to display the LineString as a line (it's road data) and not as polygons?


Polymaps use SVG Path to render Linestring. You have to set the fill attribute to none

  .on("load", po.stylist()
  .attr("fill", "none")

http://www.w3.org/TR/SVG/paths.html#PathElement

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号