Tạo lớp MapLayer để chứa dữ liệu địa lý của đối tượng và cách thể hiện của nó thông qua lớp DefaultMapLayer là hiện thực của interface MapLayer.
Sau khi tạo ra các mapLayer ta tích hợp các lớp này vào trong 1 mapContext thông qua phương thức addLayer(), phương thức này có khả năng nhận vào featureSource và style để tự động tạo thành MapLayer trong ContextMap hoặc nhận vào MapLayer đã được tạo trước từ featureSource và style.
Method Summary
|
void
|
addLayer(FeatureCollection collection, Style style)
Add a new layer and trigger a LayerListEvent.
|
void
|
addLayer(FeatureSource featureSource, Style style)
Add a new layer and trigger a LayerListEvent.
|
boolean
|
addLayer(int index,MapLayer layer)
Add a new layer in the specified position and trigger a LayerListEvent.
|
boolean
|
addLayer(MapLayer layer)
Add a new layer if not already present and trigger a LayerListEvent.
|
int
|
addLayers(MapLayer[] layers)
Add an array of new layers and trigger a LayerListEvent.
|
void
|
addMapBoundsListener(MapBoundsListener listener)
Register interest in receiving MapBoundsEvents.
|
void
|
addMapLayerListListener(MapLayerListListener listener)
Register interest in receiving a LayerListEvent.
|
void
|
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Registers PropertyChangeListener to receive events.
|
void
|
clearLayerList()
Clears the whole layer list.
|
java.lang.String
|
getAbstract()
Get the abstract which describes this interface, returns an empty string if this has not been set yet.
|
com.vividsolutions.jts.geom.Envelope
|
getAreaOfInterest()
Gets the current area of interest.
|
java.lang.String
|
getContactInformation()
Get the contact information associated with this context, returns an empty string if contactInformation has not been set.
|
org.opengis.referencing.crs.CoordinateReferenceSystem
|
getCoordinateReferenceSystem()
Get the current coordinate system.
|
java.lang.String[ ]
|
getKeywords()
Get an array of keywords associated with this context, returns an empty array if no keywords have been set.
|
MapLayer
|
getLayer(int index)
Return the requested layer.
|
com.vividsolutions.jts.geom.Envelope
|
getLayerBounds()
Get the bounding box of all the layers in this MapContext.
|
int
|
getLayerCount()
Returns the number of layers in this map context
|
MapLayer[ ]
|
getLayers()
Return this model's list of layers.
|
java.lang.String
|
getTitle()
Get the title, returns an empty string if it has not been set yet.
|
int
|
indexOf(MapLayer layer)
Returns the index of the first occurrence of the specified layer, or -1 if this list does not contain this element.
|
java.util.Iterator
|
iterator()
Returns an iterator over the layers in this context in proper sequence.
|
void
|
moveLayer(int sourcePosition, int destPosition)
Moves a layer from a position to another.
|
MapLayer
|
removeLayer(int index)
Remove a layer and trigger a LayerListEvent.
|
boolean
|
removeLayer(MapLayer layer)
Remove a layer, if present, and trigger a LayerListEvent.
|
void
|
removeLayers(MapLayer[] layers)
Remove an array of layers and trigger a LayerListEvent.
|
void
|
removeMapBoundsListener(MapBoundsListener listener)
Remove interest in receiving a BoundingBoxEvents.
|
void
|
removeMapLayerListListener(MapLayerListListener listener)
Remove interest in receiving LayerListEvent.
|
void
|
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes PropertyChangeListener from the list of listeners.
|
void
|
setAbstract(java.lang.String conAbstract)
Set an abstract which describes this context.
|
void
|
setAreaOfInterest(com.vividsolutions.jts.geom.Envelope areaOfInterest)
Set a new area of interest and trigger an BoundingBoxEvent.
|
void
|
setAreaOfInterest(com.vividsolutions.jts.geom.Envelope areaOfInterest, org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem)
Set a new area of interest and trigger a BoundingBoxEvent.
|
void
|
setContactInformation(java.lang.String contactInformation)
Set contact inforation associated with this class.
|
void
|
setKeywords(java.lang.String[] keywords)
Set an array of keywords to associate with this context.
|
void
|
setTitle(java.lang.String title)
Set the title of this context.
|
void
|
transform(java.awt.geom.AffineTransform transform)
Transform the coordinates according to the provided transform.
|
Vì StyledMapPane thực chất là một JComponent nên muốn hiển thị ra màn hình ta cần đặt StyleMapPane vào trong JFrame hoặc Applet, JApplet.
B1: Khai báo cách đọc dữ liệu từ các file .shp theo kiểu đọc file để đóng gói chạy trên Web giống như hướng dẫn đọc dữ liệu từ file .shp ở trên.
B2: Tạo Applet hay JApplet chứa StyledMapPane.
B3: Đóng gói trong java bằng cách vào File à New àArchive chọn Basic.