OpenLayers is powerful and versatile but sometimes difficult to use. This repository contains various components that facilitate its use in specific aspects, but without renouncing the possibility of customization.
- Improve drawing and editing tools
- Control.DrawFeature: Allows esc-key to cancel addition of last vertex.
- Control.ModifyFeature: Multiple improvements.
- Format.KML: Allows highlight features.
- Strategy.Cluster: Centering the clusters.
- Components in other jorix's repositories.
- OL-FeaturePopups: Automate selection and show popups using templates.
- OL-DynamicMeasure: Show measurements at the cursor.
- Cancels addition of last vertex by esc-key
- Centering the first vertex the feature is deleted.
- (Provided by Path-patch.js)
- Allows usage multilayer also using SelectFeature.
- Allow delete a feature that have been selected for modification (by a button)
- Cancel a drag pressing esc-key.
- Separate representation for each tool (rotate, resize ...)
- Use icons to identify the tools.
- Configurable styles are used to show the tools (independent of the layer styleMap)
- Also uses Configurable styles to show vertices (independents of the layer styleMap)
- Allows add custom tools (eg drag attributes as a angle attribute of a point)
- (Provided by ModifyFeature-tools.js)
See examples:
- Draw & modify and custom tools modify-feature.html
- Multilayer usage without SelectFeature control modify-feature-multilayer.html
- Multilayer usage with SelectFeature control modify-feature-selectFeature.html
See example of multilayer usage modify-feature-multilayer.html
Allows use both "normal" and "highlight" styles from KML using with extracStyles:true
- See example sundials.html
- (Provided by KML-patch.js)
The OL Cluster algorithm is simple and efficient, but a cluster with two points shown centered on one of them, see DEV: cluster coord update proposition
The CenteredCluster
proposal uses the OL algorithm as the main piece to group points and subsequently refine cluster. Enough to improve outcome: clusters with few points are shown centered. Less cluster with more points, and is satisfied that all points are within the selected distance. There may be fewer clusters closer than the distance set, but if presents, are few and the separation between them is not much smaller than the set distance.
NOTE: This represents a considerable increase of the calculations to be performed, but has been done a implementation to optimize performance, so in the majority of cases CenteredCluster
is as fast as than OL Cluster strategy.
- See example strategy-centered-cluster-log-timed.html (comparison between
CenteredCluster
and OL Cluster strategies) - (Provided by CenteredCluster.js)
- Methods
activate
anddeactivate
makes cluster and uncluster the features. - Use adaptive settings depending on the level of zoom (allowed settings:
enabled
,distance
,threshold
andcentered
), see sundials-cluster.html - New properties in respect of OL Cluster:
- centered: clusters are centered on the points they represent (default value is true)
- candidateMatches: optional function that replaces the OL
shouldCluster
(see strategy-cluster-extended.html) - enabled: if false the features are shown unclustered.
- zoomSettings: allows different settings depending on the zoom ranges.
- Allows add and remove individual features dynamically, see strategy-centered-cluster-add-remove.html
NOTE: This code includes a patch for getDataExtent
of OpenLayers.Layer.Vector
.
To use any component need only add it after the declaration of <script src="... /OpenLayers.js"></script>
.
This components could be used in a custom *.cfg
file to compress javaScript since in the code has been declared the appropriate clauses of @requires
(see OL manual minimizing-build-size)
See also OL-ragbag API documentation:
- API for users
- For developers all elements
The components (if not stated otherwise in component description) works correctly with release from 2.11 to 2.13 and the OL development version.
NOTES:
- Most of the examples used are adaptations of OpenLayers examples (this examples have their original name)
- Use examples for development if you want to try a example using another OL release or unpatched, the examples of development has the same name with the suffix
-dev
.