geoJSONファイルをGoogleマップにデータレイヤとして読み込むとき、データレイヤ自体のプロパティにどのようにアクセスしますか?GoogleマップV3のGeoJSONデータレイヤのプロパティの取得
私は、以下の例のposts_here
のように、access the individual propertiesの方法を知っています。取得しようとしているのは、レイヤー自体のプロパティです。この例では、maxPosts
です。 grid.json
私はロードてるの
$.getJSON("http://example.com/posts/grid.json" + location.search, function (data) {
grid = map_canvas.data.addGeoJson(data);
map_canvas.data.setStyle(function(feature) {
return /** @type {google.maps.Data.StyleOptions} */({
strokeWeight: Math.log(feature.getProperty('posts_here')),
});
})
});
例:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-58,-35],
[-58,-34],
[-57,-34],
[-57,-35],
[-58,-35]
]
]
},
"properties": {
"posts_here": "177"
}
}
],
"properties": {
"maxPosts": "177"
}
}
を経由してプロパティにアクセスすることができます。自己への教訓:console.log()EVERYTHING。 – schnauss