JMap Server Lima
JMap Server SDK
JMap Server SDK
  • Welcome to JMap Server SDK
  • General Concepts
  • JMap Pro and JMap Server Development
    • JMap Pro
      • Class Model
      • Map Elements
      • Coordinate Systems
      • Views and View Manager
      • Layers and Layer Manager
      • JMap Pro Application
      • Client-Server Communication
      • List of GUI Components
      • JMap Tools
      • JMap Pro Extensions
      • Integrating JMap Pro With Other Applications
      • References
    • JMap Server
      • JMap Server Extensions
    • JMap 7 API
    • JMap Pro Extension Builder
  • JMap Web Development
    • JMap Web Extensions
      • Programming JMap Web extensions
      • Sending Server Requests and Custom Actions
      • Default JMap Web Actions
      • Deploying JMap Web Extensions
    • Embedding a JMap Web Deployment Into Your own Application
Propulsé par GitBook
Sur cette page
  • Concepts
  • The Layer class and its derived classes
  • Layer class
  • VectorLayer class
  • RasterLayer class
  • Layer class events
  • LayerManager class
  • LayerManager class events
Exporter en PDF
  1. JMap Pro and JMap Server Development
  2. JMap Pro

Layers and Layer Manager

PrécédentViews and View ManagerSuivantJMap Pro Application

Dernière mise à jour il y a 7 mois

K2 Geospatial 2024

Concepts

Layers ( class and its related classes) are highly important in JMap programming. They contain and manage the map data displayed on the map ( class). There are two main types of layers: vector layers ( class), which contain vector data, and raster layers ( class), which contain raster data (images).

When a project is loaded, the client application gets the layer configuration from the server and creates the related instances in the . Initially, a layer does not contain any data. Its data will only be loaded, in full or in part, after the view has been refreshed, based on the loading mode and display restrictions (visibility state and display thresholds).

In JMap, there are two different modes to load layers: by tile and by region. Vector layers support both modes, but raster layers can only be loaded by region.

Tiled layers divide the region of the layer into rows and columns; each cell is a data tile ( and classes). Since the layers are initially empty at application startup, data tiles will be loaded by the application when they are initially displayed in a view. Once it is loaded in a layer, a tile will be kept in memory for the duration of the session, unless the session expires prematurely or the memory manager decides to delete the tile.

When a data tile request is sent to JMap Server, all geometries ( interface) intersecting the region of the tile will be transferred to the client. Once the tile is received, the geometries will be transformed into elements ( class), which will then be loaded in the of the layer. To avoid duplicating an element in several data tiles, elements that are not completely included in a tile will eventually be moved to the layer’s universe tile.

Layers loaded by region are based on the same structure ( and classes), but they only have a single tile with a variable region. When a change is applied to the transformation matrix of the view and the view is refreshed, layers loaded by region will reload their single tile with the data intersecting the extent of the view.

The Layer class and its derived classes

Layer class

The Layer class is abstract and therefore cannot be instantiated. However, it provides the basic methods for all layers.

The following table shows the most commonly used methods of the class.

Adds a listener to the events generated by the layer.

Returns the unique numerical ID of the layer.

Returns the layer name.

Static method that generates a new unique identifier for a user layer.

Invalidates the cache of a layer loaded by region. This allows the layer to be refreshed when no changes have been made to the view transformation matrix.

Indicates if the layer is displayed at the specified scale according to the defined display thresholds.

Indicates whether or not the layer objects are selectable.

Indicates whether or not the layer is visible.

Returns a serializable data structure containing all of the layer’s information.

VectorLayer class

Vector layers have a set of attributes that are common to all elements of the layer. These attributes provide the descriptive data of the layer’s elements.

Adds the specified element on the layer.

Adds all specified elements on the layer.

Adds the specified element to the list of selected elements.

Adds a collection of elements to the list of selected elements.

Clears the list of selected objects on this layer.

Returns a collection containing all of the layer's elements.

Returns the total extent of the layer data as a rectangle.

Returns an array containing all the elements selected on the layer.

RasterLayer class

Returns the total extent of layer data as a rectangle.

Layer class events

The layers in JMap generate events in several situations. To get the events generated by a layer, you must register a listener on the layer. To get the events generated by all the layers of the project, it is recommended to register a listener on the layer manager. See below for more information on this subject.

Layer layer = ...

layer.addLayerEventListener(new LayerEventListener()

{

@Override

public void layerSelChangedEventOccurred(LayerSelChangedEvent e)

{

// TODO

}

...

});

Launched after new elements are added to the layer. The added elements are accessible in the instance of the event.

Launched after changing elements on the layer. Changed items are available in the instance of the event.

Launched after removing elements from the layer. The removed elements are available in the instance of the event.

Launched after changing the selection on the layer; this can include selected or unselected events. The elements in question are available in the instance of the event.

Launched after changing the style of the layer.

LayerManager class

Adds the specified layer to the highest position.

Adds a listener to events generated by the layer manager. The layer manager also relays all the events generated by the layers it manages.

Clears the list of selected elements on each layer.

Returns the ordered set of layers (user layers and normal layers). The layer at the zero position is the bottom layer.

Returns the layer having the specified unique identifier.

Returns the layer having the specified unique name.

Returns the position of the specified layer.

Returns a data structure (LayerVisibilitySet class) containing the visibility state of a layer. This state considers the state of the selection of groups in the layer hierarchy as well as the configuration of their visibility.

Returns all the selected elements on all layers.

Returns the extent of all selected elements on all layers.

Removes the layer located at the specified position.

LayerManager class events

The layer manager in JMap generates events. To receive the events generated by a layer manager, you must register a listener on the appropriate layer manager. Note that a listener registered on the layer manager will get the events generated by all the layers handled by the layer manager.

The following table shows the most commonly events of the layer manager.

Launched after changing the position of a layer in the list of layers handled by the layer manager.

Launched after removing a layer from the list of layers handled by the layer manager.

Launched after adding a layer to the list of layers handled by the layer manager.

Returns the type of elements contained in the layer. Types are defined by the constants of the class.

Returns the instance of the Style Manager ( class) used by the layer. It manages all of the layer styles, which define the graphical appearance of elements on the map.

The class is derived from the Layer class and contains only vector data. It has several specialized methods for vector data to generate element selections, perform spatial analysis, etc.

The following table shows the most commonly used methods of the class.

Returns the list of attributes ( class) of the layer.

Adds a new display filter ( interface) to the layer. This filter allows you to define what will be displayed and what won't.

Provides the first element of the layer detected at the specified coordinates in WC in the specified map ( class). The last parameter determines if the elements that are invisible (due to a display filter, for example) should be considered or not.

Returns all of the layer's elements identified at the specified WC coordinates in the specified map ( class). The last parameter determines if the elements that are invisible (due to a display filter, for example) should be considered or not.

Returns all of the layer's elements that intersect the surface specified in WC coordinates in the specified map ( class). The last parameter determines if the elements that are invisible (due to a display filter, for example) should be considered or not.

The class is derived from the Layer class and contains only raster data. Its methods are rarely used by JMap application developers.

The following table shows the most commonly used methods of the class.

Returns the raster parameters ( class) used by the raster layer (e.g. the size of the image, transparency, etc.).

Returns an array of attributes for the various bands ( class) contained in the image.

To receive the events of a layer, you must implement the interface and register it with the layer using the method, as shown in the following example:

There is also an adapter () that simplifies the development of the listener. The superclass has a getLayer() method and a getLayerManager() method allowing you to access the layer or layer manager that generated the event

The following table shows the events triggered by the class.

In JMap, each map ( class) has a layer manager ( class). The latter is responsible for managing all of the layers to be shown on the map, as well as their order and hierarchical organization. In addition, the layer manager can listen for events on all layers and perform certain operations on them.

The following table shows the most commonly used methods of the class.

To receive the layer manager’s events, you must implement the interface and register it with the layer manager using the method.

Layer
View
VectorLayer
RasterLayer
LayerManager
TileSet
Tile
Geometry
K2DElement
TileSet
TileSet
Tile
Layer
VectorLayer
VectorLayer
RasterLayer
RasterLayer
LayerEventListener
addLayerEventListener()
LayerAdapter
LayerEvent
Layer
View
LayerManager
LayerManager
LayerEventListener
addLayerEventListener()
addLayerEventListener (LayerEventListener)
getElementType()
ElementTypes
getId()
getName()
getStyleManager()
StyleManager
getNextUserLayerId()
invalidate()
isDrawable(double)
isSelectable()
isVisible()
toLayerInfo()
addElement(K2DElement)
addElements(K2DElement)
addToSelection(K2DElement)
addToSelection(Collection)
clearSelection()
getAttributeMetaData()
Attribute
addDisplayFilter(DisplayFilter)
DisplayFilter
getElementAtPoint (Point, ViewState, boolean)
ViewState
getElements()
getElementsAtPoint (Point WCCoord, ViewState viewScale, boolean onlyIfVisible)
ViewState
getElementsInSurface (Surface, ViewState, boolean)
ViewState
getExtent()
getSelectedElements()
getExtent()
getParameters()
RasterParameters
getRasterBands()
RasterBand
layerElementsAddedEventOccurred(LayerElementsAddedEvent)
layerElementsChangedEventOccurred(LayerElementsChangedEvent)
layerElementsRemovedEventOccurred(LayerElementsRemovedEvent)
layerSelChangedEventOccurred(LayerSelChangedEvent)
layerStyleChangedEventOccurred(LayerStyleChangedEvent)
addLayer(Layer)
addLayerEventListener (LayerEventListener)
clearAllSelection()
getAllLayers()
getLayer(int)
getLayer(String)
getLayerPos(Layer)
getLayerTreeVisibility()
getSelectedElements()
getSelectedExtent()
removeLayer(int)
layerPosChangedEventOccurred (LayerPosChangedEvent)
layerRemovedEventOccurred (LayerRemovedEvent)
layerAddedEventOccurred (LayerAddedEvent)