1

所以我作为初学者尝试了 polymaps,改编了午夜指挥官的例子:

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"));

我以 geoJson 格式在本地加载一些道路:

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

GeoJson 示例:

{"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": ""}}]}

现在 mylines.geojson 显示,但它不是显示为一条线,而是显示为多边形。

我的问题是,我需要做什么才能让 Polymaps 将 LineString 显示为一条线(它是道路数据)而不是多边形?

4

1 回答 1

1

Polymaps 使用 SVG Path 来渲染 Linestring。您必须将填充属性设置为无

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

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

于 2011-08-06T08:52:31.283 回答