GeoJsonLayer更改setOnFeatureClickListener

时间:2017-09-04 09:03:24

标签: android google-maps-android-api-2 geojson

您好我正在使用maps-utils实现Google Maps android。我添加了一个 GeoJsonLayer (LineString),现在我想在用户点击GeoJsonLayer的一个功能后更改功能样式(颜色和宽度)。到目前为止,我还没有找到任何与特征风格相关的属性。

road_layer=new GeoJsonLayer(mMap,R.raw.road_survey,this);
road_layer.setOnFeatureClickListener(new   Layer.OnFeatureClickListener() {
            @Override
            public void onFeatureClick(Feature feature) {

              //implement feature related operations 

            }
});

1 个答案:

答案 0 :(得分:1)

在阅读Google Maps Android GeoJSON Utility文档后,我设法实现了我的目标

road_layer=new GeoJsonLayer(mMap,R.raw.road_survey,this);
road_layer.setOnFeatureClickListener(new   Layer.OnFeatureClickListener() {
        @Override
        public void onFeatureClick(Feature feature) {
          GeoJsonLineStringStyle lineStringStyle = new GeoJsonLineStringStyle();
          lineStringFeature = (GeoJsonFeature) feature;
          lineStringStyle.setColor(Color.RED);
          lineStringStyle.setZIndex(10f);
          lineStringStyle.setWidth(2f);
          lineStringFeature.setLineStringStyle(lineStringStyle);

        }
});