尝试在标记点击时从JSON检索值

时间:2015-04-30 18:40:43

标签: javascript json

当我点击特定的地图标记(leaflet.js)时,如何从geoJSON中检索value属性?我尝试了以下和类似的代码,但我似乎无法让它工作。

示例geoJSON

var geojsonFeature = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "marker-color": "#f85047",
                "marker-size": "medium",
                "value": 130
            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    146.3622826337814,
                    -41.187067757423826
                ]
            }
        },
    ]
};

JS

marker.on('click', function(e){
    alert(this.geojsonFeature.features.properties.value);
});

以下是JSFiddle

0 个答案:

没有答案