Package 

Class GeoJsonLayer


  • 
    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();}

    • 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 rendered
        geoJsonFile - GeoJSON data to add to the layer
        markerManager - marker manager to create marker collection from
        polygonManager - polygon manager to create polygon collection from
        polylineManager - polyline manager to create polyline collection from
        groundOverlayManager - 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 rendered
        resourceId - GeoJSON file to add to the layer
        context - context of the application, required to open the GeoJSON file
        markerManager - marker manager to create marker collection from
        polygonManager - polygon manager to create polygon collection from
        polylineManager - polyline manager to create polyline collection from
        groundOverlayManager - 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 rendered
        geoJsonFile - 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 rendered
        resourceId - GeoJSON file to add to the layer
        context - 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

      • 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.