0
私はGeojsonレイヤーを取り入れて、色を付けたいと思います。下のコードでは、領域の上に黒い線しか表示されません。その部分は正しいです、私はちょうどその領域に色や陰影を追加する必要があります。しかし、私は機能モデルgeojsonオブジェクト/ geolayerの色と陰影領域をGoogleマップのために設定します。sdk android
public class Features {
private Properties properties;
private String type;
private Geometry geometry;
public Properties getProperties() {
return properties;
}
public void setProperties(Properties properties) {
this.properties = properties;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Geometry getGeometry() {
return geometry;
}
public void setGeometry(Geometry geometry) {
this.geometry = geometry;
}
@Override
public String toString() {
return "ClassPojo [properties = " + properties + ", type = " + type + ", geometry = " + geometry + "]";
}
}
は、次に面積が基づいているもの
private void drawNeighborhood(int neighborhoodIndex) {
try {
mMap.clear();
if (mViewModel.validateNeighborboodsState()) {
return;
}
Features[] featuresArray = mViewModel.getFeature();
final LatLngBounds.Builder builder = LatLngBounds.builder();
if (featuresArray.length > neighborhoodIndex) {
Features currentFeature = featuresArray[neighborhoodIndex];
GeoJsonLayer geoJsonLayer = getGeoJsonLayer(currentFeature);
createViewArea(builder, currentFeature);
final CameraUpdate cameraUpdate =
CameraUpdateFactory.newLatLngBounds(builder.build(), 200);
mMap.animateCamera(cameraUpdate);
geoJsonLayer.addLayerToMap();
}
} catch (JSONException e) {
Timber.e("GeoJSON file could not be converted to a JSONObject");
}
}
private GeoJsonLayer getGeoJsonLayer(Features features) throws JSONException {
Gson gson = new Gson();
String raw = gson.toJson(features);
JSONObject json = new JSONObject(raw);
return new GeoJsonLayer(mMap, json);
}
にGeoJSONまたはgeolayerオブジェクトでこれを行うには任意の簡単な方法を見ていないです。 (常に線ではなく多角形であることに注意してください)。バニラジオジソン仕様でなければならない
public class Geometry {
private String type;
private String[][][] coordinates;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String[][][] getCoordinates() {
return coordinates;
}
public void setCoordinates(String[][][] coordinates) {
this.coordinates = coordinates;
}
@Override
public String toString() {
return "ClassPojo [type = " + type + ", coordinates = " + coordinates + "]";
}
}