Package com.google.maps.android.data
Class Layer
- java.lang.Object
-
- com.google.maps.android.data.Layer
-
- Direct Known Subclasses:
GeoJsonLayer
,KmlLayer
public abstract class Layer extends java.lang.Object
An abstraction that shares the common properties ofKmlLayer
andGeoJsonLayer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Layer.OnFeatureClickListener
Callback interface for when a map object is clicked.
-
Constructor Summary
Constructors Constructor Description Layer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addLayerToMap()
Feature
getContainerFeature(java.lang.Object mapObject)
GeoJsonLineStringStyle
getDefaultLineStringStyle()
Gets the default style used to render GeoJsonLineStrings.GeoJsonPointStyle
getDefaultPointStyle()
Gets the default style used to render GeoJsonPoints.GeoJsonPolygonStyle
getDefaultPolygonStyle()
Gets the default style used to render GeoJsonPolygons.Feature
getFeature(java.lang.Object mapObject)
Retrieves a corresponding Feature instance for the given Object Allows maps with multiple layers to determine which layer the Object belongs to.java.lang.Iterable<? extends Feature>
getFeatures()
Gets an iterable of all Feature elements that have been added to the layercom.google.android.gms.maps.GoogleMap
getMap()
Gets the map on which the layer is renderedboolean
isLayerOnMap()
Checks if the current layer has been added to the mapvoid
removeLayerFromMap()
Removes all the data from the map and clears all the stored placemarksvoid
setMap(com.google.android.gms.maps.GoogleMap map)
Renders the layer on the given map.void
setOnFeatureClickListener(Layer.OnFeatureClickListener listener)
Sets a single click listener for the entire GoogleMap object, that will be called with the corresponding Feature object when an object on the map (Polygon, Marker, Polyline) is clicked.
-
-
-
Method Detail
-
addLayerToMap
public abstract void addLayerToMap()
-
removeLayerFromMap
public void removeLayerFromMap()
Removes all the data from the map and clears all the stored placemarks
-
setOnFeatureClickListener
public void setOnFeatureClickListener(Layer.OnFeatureClickListener listener)
Sets a single click listener for the entire GoogleMap object, that will be called with the corresponding Feature object when an object on the map (Polygon, Marker, Polyline) is clicked.If getFeature() returns null this means that either the object is inside a KMLContainer, or the object is a MultiPolygon, MultiLineString or MultiPoint and must be handled differently.
- Parameters:
listener
- Listener providing the onFeatureClick method to call.
-
getFeatures
public java.lang.Iterable<? extends Feature> getFeatures()
Gets an iterable of all Feature elements that have been added to the layer- Returns:
- iterable of Feature elements
-
getFeature
public Feature getFeature(java.lang.Object mapObject)
Retrieves a corresponding Feature instance for the given Object Allows maps with multiple layers to determine which layer the Object belongs to.- Parameters:
mapObject
- Object- Returns:
- Feature for the given object
-
getContainerFeature
public Feature getContainerFeature(java.lang.Object mapObject)
-
getMap
public com.google.android.gms.maps.GoogleMap getMap()
Gets the map on which the layer is rendered- Returns:
- map on which the layer is rendered
-
setMap
public void setMap(com.google.android.gms.maps.GoogleMap map)
Renders the layer on the given map. The layer on the current map is removed and added to the given map.- Parameters:
map
- to render the layer on, if null the layer is cleared from the current map
-
isLayerOnMap
public boolean isLayerOnMap()
Checks if the current layer has been added to the map- Returns:
- true if the layer is on the map, false otherwise
-
getDefaultPointStyle
public GeoJsonPointStyle getDefaultPointStyle()
Gets the default style used to render GeoJsonPoints. Any changes to this style will be reflected in the features that use it.- Returns:
- default style used to render GeoJsonPoints
-
getDefaultLineStringStyle
public GeoJsonLineStringStyle getDefaultLineStringStyle()
Gets the default style used to render GeoJsonLineStrings. Any changes to this style will be reflected in the features that use it.- Returns:
- default style used to render GeoJsonLineStrings
-
getDefaultPolygonStyle
public GeoJsonPolygonStyle getDefaultPolygonStyle()
Gets the default style used to render GeoJsonPolygons. Any changes to this style will be reflected in the features that use it.- Returns:
- default style used to render GeoJsonPolygons
-
-