Package com.jbstrap.jbmap.layers
Class BaseLayer<T extends BaseLayer<?>>
- Type Parameters:
T- The layer class type
- Direct Known Subclasses:
Area,Circle,CirclePoint,DivPoint,Line,Point,PopupPoint,Rectangle
The base class of all layers.
All map layers must be extended from this layer.
This class ensures the basic functionalities of layers:
event handling, GeoJSON structure, coordinates, unique parameters, popup settings, and being assigned to a layer group.
Supported events:- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected LayerStyleprotected static final Stringprotected static final Stringprotected static final Stringprotected Popupprotected static final Stringprotected static final Stringprotected static final Stringprotected static final StringFields inherited from class com.jbstrap.jbmap.layers.Layer
componentContent, params, parent -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddClickHandler(LayerClickEventHandler handler) Adds a layer click event handler to the layer.addCustomParam(String name, Object value) Adds a custom parameter to the layer.Adds a mouse out event handler to the layer.Adds a layer mouse over event handler to the layer.Closes the displayed popup.List<com.jbstrap.core.event.handlers.BrowserEventHandler>Gets a list of layer click event handlers.com.jbstrap.core.ParametersGets the layer's unique parameters.protected com.jbstrap.core.ParametersList<com.jbstrap.core.event.handlers.BrowserEventHandler>Gets a list of mouse out event handlers.List<com.jbstrap.core.event.handlers.BrowserEventHandler>Gets a list of layer mouse over event handlers.getName()Gets the layer's unique name.com.jbstrap.core.ParametersGets the layer's full list of parameters.Gets the layer group of the layer.getPopup()Gets the layer popup as a JBStrap component.Gets the layer popup content.final com.jbstrap.core.ParametersGets the setting parameters of the layer's GeoJSON structure.getTitle()Gets the layer's titlehide()The layer is programmatically hidden.booleanChecks if the popup is enabled.booleanisShown()Gets the status of the layer's programmatical display.Displays the popup if enabled.removeClickHandler(LayerClickEventHandler handler) Removes the layer click event handler from the list of click event handlers.removeCustomParam(String name) Removes the parameter with the specified name from the layer's custom parameters.Removes a mouse out event handler from the list of mouse out event handlers.Removes the layer mouse over event handler from the list of mouse over event handlers.protected voidrunJSLayer(String script) protected voidrunJSLayerGroup(String script) protected voidsetCoordinates(List<Double> coordinateList) setCustomParams(com.jbstrap.core.Parameters customParams) Sets the layer's unique parameters.final TsetParent(LayerGroup parent) Sets the layer's parent (the layer group).setPopupContent(String popupContent) Sets the layer popup content once as a text.setPopupEnabled(boolean popupEnabled) Enabled the popup.Sets the layer's title.show()The layer is displayed programmatically.Methods inherited from class com.jbstrap.jbmap.layers.Layer
getContent, runAfterDrawOnLayer, runOnHideOnLayer, runOnShowOnLayer
-
Field Details
-
TYPE
- See Also:
-
NAME
- See Also:
-
POPUP_CONTENT
- See Also:
-
POPUP_ENABLED
- See Also:
-
POPUP_OPENED
- See Also:
-
POINT_TYPE
- See Also:
-
POINT
- See Also:
-
COORDINATES
- See Also:
-
layerStyle
-
popup
-
-
Constructor Details
-
BaseLayer
Creates the base class of a layer.- Parameters:
name- The layer's unique name for identifying the layer Specify this name to get the layer from the containing LayerGroup.- Throws:
NullPointerException- Thrown if the name parameter isnull
-
-
Method Details
-
getPopup
Gets the layer popup as a JBStrap component. If you get the layer popup component, you can add any JBStrap component to the popup.- Returns:
- Layer popup component
-
addClickHandler
Adds a layer click event handler to the layer. This handler is executed only once if the user clicks on the layer.- Parameters:
handler- TheLayerClickEventHandlerimplementation- Returns:
- The instantiated Layer class
-
getClickHandlers
Gets a list of layer click event handlers.- Returns:
- A list of layer click event handlers
-
removeClickHandler
Removes the layer click event handler from the list of click event handlers. The removed event handler does not apply to the event.- Parameters:
handler- TheLayerClickEventHandlerto be removed- Returns:
- The instantiated Layer class
-
addMouseOverHandler
Adds a layer mouse over event handler to the layer. This handler is executed if the user hovers with the mouse over the layer.- Parameters:
handler-LayerMouseOverEventHandlerimplementation- Returns:
- The instantiated Layer class
-
getMouseOverHandlers
Gets a list of layer mouse over event handlers.- Returns:
- A list of mouse over event handlers
-
removeMouseOverHandler
Removes the layer mouse over event handler from the list of mouse over event handlers. The removed event handler does not apply to the event.- Parameters:
handler- TheLayerMouseOverEventHandlerto be removed- Returns:
- The instantiated Layer class
-
addMouseOutHandler
Adds a mouse out event handler to the layer. This handler is executed if the user's mouse pointer leaves the layer.- Parameters:
handler- TheLayerMouseOutEventHandlerimplementation- Returns:
- The instantiated Layer class
-
getMouseOutHandlers
Gets a list of mouse out event handlers.- Returns:
- A list of mouse out event handlers assigned to the layer
-
removeMouseOutHandler
Removes a mouse out event handler from the list of mouse out event handlers. The removed event handler does not apply to the event.- Parameters:
handler- TheLayerMouseOutEventHandlerto be removed- Returns:
- The instantiated Layer class
-
setParent
Sets the layer's parent (the layer group). You can add a layer to a layer groupLayerGroup.addLayer(BaseLayer)or set its parent, the layer group. The latter way can also be used to move a layer to another layer.- Parameters:
parent- The layer group- Returns:
- Layer class instance
-
getParent
Gets the layer group of the layer. You get the layer group to which the layer is added.- Returns:
- The layer group that currently holds the layer If not available, its value is
null.
-
getName
Gets the layer's unique name. Use this name to identify a layer. Two layers cannot have the same name in the same layer group.- Returns:
- Unique layer name
-
getTitle
Gets the layer's title- Returns:
- Layer title
-
setTitle
Sets the layer's title. This title is not displayed on the UI, but it exists as a parameter. E.g. it can be used as atitleParamcomponent on theDivLayerinstance.- Parameters:
title- Layer title- Returns:
- Layer class instance
-
getPopupContent
Gets the layer popup content. The content that was specified using thesetPopupContent(String)method.- Returns:
- Layer popup content
-
setPopupContent
Sets the layer popup content once as a text. If you want to set a JBStrap content, you have to use thegetPopup()method.- Parameters:
popupContent- Layer popup text- Returns:
- Layer class instance
-
isPopupEnabled
public boolean isPopupEnabled()Checks if the popup is enabled.- Returns:
- If
true, the popup is enabled, otherwise not
-
setPopupEnabled
Enabled the popup.- Parameters:
popupEnabled- Iftrue, the layer popup is enabled, otherwise not The default setting isfalse.- Returns:
- Layer class instance
-
openPopup
Displays the popup if enabled. If the popup display is not enabled, you can do this by using thesetPopupEnabled(boolean)method. If you use this method at initialization time, the popup shows up as open on the layer. The layer also has to be visible on the map.- Returns:
- Layer class instance
-
closePopup
Closes the displayed popup.- Returns:
- Layer class instance
-
setCoordinates
- Parameters:
coordinateList- A list of Double type containing longitude and latitude coordinates
-
getGeometry
protected com.jbstrap.core.Parameters getGeometry()- Returns:
- Geometrical parameters
-
getProperties
public final com.jbstrap.core.Parameters getProperties()Gets the setting parameters of the layer's GeoJSON structure.- Returns:
- Setting parameters of the layer's GeoJSON structure
-
getCustomParams
public com.jbstrap.core.Parameters getCustomParams()Gets the layer's unique parameters.- Returns:
- The layer's unique parameters
-
setCustomParams
Sets the layer's unique parameters. You can use theaddCustomParam(String, Object)method to add a parameter.- Parameters:
customParams- The layer's custom parameters- Returns:
- Layer class instance
-
addCustomParam
Adds a custom parameter to the layer.- Parameters:
name- Parameter namevalue- Parameter value- Returns:
- Layer class instance
- Throws:
NullPointerException- Thrown if the name parameter isnull
-
removeCustomParam
Removes the parameter with the specified name from the layer's custom parameters.- Parameters:
name- Parameter name- Returns:
- Layer class instance
- Throws:
NullPointerException- Thrown if the name parameter isnull
-
getParams
public com.jbstrap.core.Parameters getParams()Gets the layer's full list of parameters.- Returns:
- The layer's full list of parameters
-
isShown
public boolean isShown()Gets the status of the layer's programmatical display. -
show
The layer is displayed programmatically.- Returns:
- Layer class instance
-
hide
The layer is programmatically hidden.- Returns:
- Layer class instance
-
runJSLayer
- Parameters:
script- JavaScript
-
runJSLayerGroup
- Parameters:
script- JavaScript
-