[您好,我正在使用Google Maps android api,并且我正在使用Google Maps android geojson实用程序。我将3层geojson添加到地图中,只有road_layer(LineString)具有功能click事件。在添加samsad_boundary_layer(多边形)之前,单击事件工作正常。问题是,如果单击了[[samsad_boundary_layer功能,尽管该图层(samsad_boundary_layer)没有功能单击事件,但它触发了[[road_layer功能单击事件。
private void showBoundery(){
try {
samsad_boundary_layer=new GeoJsonLayer(mMap,R.raw.samsad_boundary,MapActivity.this); //1st Layer
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
samsad_boundary_layer.getDefaultPolygonStyle().setZIndex(-12f);
GeoJsonPolygonStyle polygonStyle=samsad_boundary_layer.getDefaultPolygonStyle();
polygonStyle.setStrokeWidth(5f);
polygonStyle.setStrokeColor(getResources().getColor(R.color.purple));
samsad_boundary_layer.addLayerToMap();
}
private void retrieveFileFromResource() {
try {
temp_layer=new GeoJsonLayer(mMap,R.raw.area_survey,this); //2nd Layer
temp_layer.addLayerToMap();
road_layer=new GeoJsonLayer(mMap,R.raw.road_survey,this); //3rd Layer
road_layer.setOnFeatureClickListener(new Layer.OnFeatureClickListener() {
@Override
public void onFeatureClick(Feature feature) {
if (feature!=null){
Iterator<HashMap> flavoursIter = feature.getProperties().iterator();
while (flavoursIter.hasNext()){
Map.Entry entry = (Map.Entry)flavoursIter.next();
//Log.v("SURVEYOR_FEATURE",entry.getKey().toString()+":"+entry.getValue());
}
}
}
});
GeoJsonLineStringStyle lineStyle=road_layer.getDefaultLineStringStyle();
lineStyle.setZIndex(10f);
lineStyle.setWidth(2f);
lineStyle.setColor(getResources().getColor(R.color.light_green));
road_layer.addLayerToMap();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}