无法使用geoJson实现L.mapbox.simplestyle [英] can't implement L.mapbox.simplestyle with geoJson

查看:145
本文介绍了无法使用geoJson实现L.mapbox.simplestyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为标记的大小和颜色实现simplestyle的选项,但是无法渲染它们.在这个简单的测试案例中,我尝试遵循 Mapbox自己的方法例子非常紧密:

I'm trying to implement simplestyle's options for marker size and color , but can't get them to render. In this simple test case, I'm trying to follow Mapbox's own example quite closely:

var myData = [
      {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [4.509373,51.932994]
        },
        "properties": {
             "marker-size": "large",
             "marker-color": "#ffcc00"
        }
      }
    ];

var map = L.mapbox.map('map', 'examples.map-20v6611k')
    .setView([51.932994,4.509373], 8);

L.geoJson(myData, { style: L.mapbox.simplestyle.style }).addTo(map);

小提琴

但是标记以默认样式呈现.我想念什么?

But the marker renders in default style. What am I missing?

推荐答案

好的,我已经使用

OK, I've got it working using this extended function from this page of Mapbox's documentation:

L.geoJson(myData, {
    pointToLayer: L.mapbox.marker.style,
    style: function(feature) { return feature.properties; }
}).addTo(map);

另一个Mapbox示例并没有使它看起来像需要pointToLayer参数,但是无论如何,都有效:

The other Mapbox example didn't make it look like the pointToLayer argument was required, but whatever works:

小提琴

这篇关于无法使用geoJson实现L.mapbox.simplestyle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆