-
public class GeoJsonLayer extends Layer
A class that allows the developer to import GeoJSON data, style it and interact with the imported data.
To create a new GeoJsonLayer from a resource stored locally
{@code GeoJsonLayer layer = new GeoJsonLayer(getMap(), R.raw.resource, * getApplicationContext());}To render the imported GeoJSON data onto the layer
{@code layer.addLayerToMap();}To remove the rendered data from the layer
{@code layer.removeLayerFromMap();}
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceGeoJsonLayer.GeoJsonOnFeatureClickListener
-
Constructor Summary
Constructors Constructor Description GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager)Creates a new GeoJsonLayer object. GeoJsonLayer(GoogleMap map, int resourceId, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager)Creates a new GeoJsonLayer object. GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile)Creates a new GeoJsonLayer object. GeoJsonLayer(GoogleMap map, int resourceId, Context context)Creates a new GeoJsonLayer object.
-
Method Summary
Modifier and Type Method Description voidaddLayerToMap()Adds all the GeoJsonFeature objects parsed from the given GeoJSON data onto the map Iterable<GeoJsonFeature>getFeatures()Gets an iterable of all Feature elements that have been added to the layer voidaddFeature(GeoJsonFeature feature)Adds a GeoJsonFeature to the layer. voidremoveFeature(GeoJsonFeature feature)Removes the given GeoJsonFeature from the layer LatLngBoundsgetBoundingBox()Gets the LatLngBounds containing the coordinates of the bounding box for theFeatureCollection. StringtoString()-
Methods inherited from class com.google.maps.android.data.Layer
getContainerFeature, getDefaultLineStringStyle, getDefaultPointStyle, getDefaultPolygonStyle, getFeature, getFeatures, getMap, isLayerOnMap, removeLayerFromMap, setMap, setOnFeatureClickListener -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
GeoJsonLayer
GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager)
Creates a new GeoJsonLayer object.- Parameters:
map- map where the layer is to be renderedgeoJsonFile- GeoJSON data to add to the layermarkerManager- marker manager to create marker collection frompolygonManager- polygon manager to create polygon collection frompolylineManager- polyline manager to create polyline collection fromgroundOverlayManager- ground overlay manager to create ground overlay collection from
-
GeoJsonLayer
GeoJsonLayer(GoogleMap map, int resourceId, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager)
Creates a new GeoJsonLayer object.- Parameters:
map- map where the layer is to be renderedresourceId- GeoJSON file to add to the layercontext- context of the application, required to open the GeoJSON filemarkerManager- marker manager to create marker collection frompolygonManager- polygon manager to create polygon collection frompolylineManager- polyline manager to create polyline collection fromgroundOverlayManager- ground overlay manager to create ground overlay collection from
-
GeoJsonLayer
GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile)
Creates a new GeoJsonLayer object.- Parameters:
map- map where the layer is to be renderedgeoJsonFile- GeoJSON data to add to the layer
-
GeoJsonLayer
GeoJsonLayer(GoogleMap map, int resourceId, Context context)
Creates a new GeoJsonLayer object.- Parameters:
map- map where the layer is to be renderedresourceId- GeoJSON file to add to the layercontext- context of the application, required to open the GeoJSON file
-
-
Method Detail
-
addLayerToMap
void addLayerToMap()
Adds all the GeoJsonFeature objects parsed from the given GeoJSON data onto the map
-
getFeatures
Iterable<GeoJsonFeature> getFeatures()
Gets an iterable of all Feature elements that have been added to the layer
-
addFeature
void addFeature(GeoJsonFeature feature)
Adds a GeoJsonFeature to the layer. If the point, linestring or polygon style is set tonull, the relevant default styles are applied.
- Parameters:
feature- GeoJsonFeature to add to the layer
-
removeFeature
void removeFeature(GeoJsonFeature feature)
Removes the given GeoJsonFeature from the layer
- Parameters:
feature- feature to remove
-
getBoundingBox
LatLngBounds getBoundingBox()
Gets the LatLngBounds containing the coordinates of the bounding box for theFeatureCollection. If the FeatureCollection did not have a bounding box or if the GeoJSONfile did not contain a FeatureCollection then null will be returned.
-
-
-
-