传单功能的样式不起作用

时间:2013-07-13 17:45:21

标签: javascript meteor leaflet

我一直在尝试在Leaflet地图上添加一个多边形并给它一个样式。我一直在http://leafletjs.com/examples/geojson.html上关注他们的教程,但没有成功。

我的代码如下:

var myStyle = {
  "color": "#0000FF",
  "fill": true,
  "opacity": 0.65
  };

  var myPolygon = [{
      "type": "Feature",
      "properties": {
          "name": "Poly test",
          "popupContent": "this is my test!",
      },
      "geometry": {
          "type": "Polygon",
          "coordinates": [[
              [6.0, 52],  // top right
              [5.9,  52], // top left
              [5.9,  51.5], // bottom left
              [6.0, 51.5]
          ]]
      }
  }];

    // Create a map with standard location
    map = L.map('map').setView([52.2, 6.5], 9);
  var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
  var osm = new L.TileLayer(osmUrl, {minZoom: 3, maxZoom: 14});   
  // Ask the user to get their current location
  map.locate({setView : true});
  // Add the tilelayer to the map
  map.addLayer(osm);

  L.geoJson(myPolygon, {
    style: myStyle
  }).addTo(map);

  // Add event listeners
  map.on('locationfound', myMarker);

绘制多边形外线,但使用标准蓝色。 有人能指出我正确的解决方案,如何做到这一点?

谢谢!

1 个答案:

答案 0 :(得分:1)

您需要fillColorfillOpacity,请参阅:

http://leafletjs.com/reference.html#path