use of com.google.maps.android.geojson.GeoJsonLayer in project AirMapView by airbnb.
the class NativeGoogleMapFragment method setGeoJsonLayer.
@Override
public void setGeoJsonLayer(final AirMapGeoJsonLayer airMapGeoJsonLayer) throws JSONException {
// clear any existing layers
clearGeoJsonLayer();
layerOnMap = new GeoJsonLayer(googleMap, new JSONObject(airMapGeoJsonLayer.geoJson));
GeoJsonPolygonStyle style = layerOnMap.getDefaultPolygonStyle();
style.setStrokeColor(airMapGeoJsonLayer.strokeColor);
style.setStrokeWidth(airMapGeoJsonLayer.strokeWidth);
style.setFillColor(airMapGeoJsonLayer.fillColor);
layerOnMap.addLayerToMap();
}
use of com.google.maps.android.geojson.GeoJsonLayer in project iosched by google.
the class MapUtils method processGeoJson.
public static GeoJsonLayer processGeoJson(Context context, GoogleMap mMap, JSONObject j) {
GeoJsonLayer layer = new GeoJsonLayer(mMap, j);
Iterator<GeoJsonFeature> iterator = layer.getFeatures().iterator();
final IconGenerator labelIconGenerator = MapUtils.getLabelIconGenerator(context);
while (iterator.hasNext()) {
GeoJsonFeature feature = iterator.next();
// get data
final String id = feature.getProperty("id");
final String typeString = feature.getProperty("type");
final int type = MapUtils.detectMarkerType(typeString);
final String label = feature.getProperty("title");
GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
if (type == MarkerModel.TYPE_LABEL) {
// Label markers contain the label as its icon
pointStyle = MapUtils.createLabelMarker(labelIconGenerator, id, label);
} else if (type == MarkerModel.TYPE_ICON) {
// An icon marker is mapped to a drawable based on its full type name
pointStyle = MapUtils.createIconMarker(typeString, id, false, context);
} else if (type != MarkerModel.TYPE_INACTIVE) {
// All other markers (that are not inactive) contain a pin icon
pointStyle = MapUtils.createPinMarker(context, id);
}
// If the marker is invalid (e.g. the icon does not exist), remove it from the map.
if (pointStyle == null) {
iterator.remove();
} else {
pointStyle.setVisible(true);
feature.setPointStyle(pointStyle);
}
}
return layer;
}
Aggregations