HereMaps GeoJSON Polygon单击读取属性 [英] HereMaps GeoJSON Polygon click read properties

查看:60
本文介绍了HereMaps GeoJSON Polygon单击读取属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题如下.

我有什么

  • 我有一个具有多边形和自定义属性的GeoJSON功能集
  • GeoJSON已加载到Here地图

我想要的

  • 我要检测多边形点击并读取自定义属性值

GeoJSON示例

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "properties": {
            "customProp": "heyImACustomProperty"
        },
        "geometry": {
            "type": "Polygon",
            "coordinates": [
                [
                    [
                        16.45477294921875,
                        43.51619059561274
                    ],
                    [
                        16.450481414794922,
                        43.50772499687011
                    ],
                    [
                        16.470909118652344,
                        43.5019975949657
                    ],
                    [
                        16.481552124023438,
                        43.51021500212034
                    ],
                    [
                        16.475543975830078,
                        43.518306809754804
                    ],
                    [
                        16.45477294921875,
                        43.51619059561274
                    ]
                ]
            ]
        }
    }]
}

关于GeoJSON操作的文档不是最好的.

Docs on GeoJSON manipulation are not the greatest.

谢谢.

推荐答案

以下是示例代码,可在单击时获取GeoJSON Polygon的属性值.

Here is the example code to get the property value of the GeoJSON Polygon on click.

reader = new H.data.geojson.Reader('/path/to/geojson/file.json');
  reader.parse();
  map.addLayer(reader.getLayer());

  reader.getLayer().getProvider().addEventListener("tap", function(e) {
    if(e.target instanceof H.map.Polygon) {
      console.log('Custom property value: ', e.target.getData().properties.customProp);
    }
  }); 

GeoJSON文档可在以下位置找到: https://developer.here.com/documentation/maps/topics_api/h-data-geojson-reader.html

GeoJSON documentation can be found here: https://developer.here.com/documentation/maps/topics_api/h-data-geojson-reader.html

这篇关于HereMaps GeoJSON Polygon单击读取属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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