GeoJsonLayer
Description
The GeoJSON layer uses the GeoJSON data format to draw geometric objects over the map. See the GeoJSON Layer docs for details.
GeoJsonLayer
Constructors
new GeoJsonLayer(def)
Creates a new instance of the layer.
Parameters
Initial data to load into this layer. Data can be changed after instantiation via layer.data()
.
Initial options to set on this layer. Options can be changed after instantiation via layer.options()
or layer.resetOptions()
.
Returns
Properties
A unique id of the layer.
Methods
data(data)
Gets or sets the current data for this layer.
Parameters
The layer data to be displayed.
Returns
options(options)
Gets or sets the layer options while preserving any previously set options.
Parameters
The layer options to be set.
Returns
An object containing all layer options and their current values.
GeoJsonFeatureStyle
The styling for the geometric objects.
const geoJsonData = {
type: 'Feature',
id: 'EiffelTower_linestring',
properties: {
color: 'rgba(0,0,255,0.7)', // custom color
width: 10, // custom line width
},
geometry: {
type: 'LineString',
coordinates: [
[2.2955, 48.8594],
[2.2935, 48.8594],
],
},
};
Properties
Defines the border styling for Polygon, MultiPolygon, Point and MultiPoint features.
The color of the border.
The fill color for the GeoJSON feature.
The radius for Point and MultiPoint features. Set the units in units
.
The width for LineString and MultiLineString features. Set the units in units
.
GeoJsonLayerData
The data describing the geometric object in GeoJSON format. Accepts a single GeoJSON object or an array of GeoJSON feature objects.
const geoJsonData = {
type: 'Feature',
id: 'EiffelTower_polygon',
properties: {
color: 'rgba(0,255,0,0.3)',
},
geometry: {
type: 'Polygon', // the polygon is a rectangle around the Eiffel Tower
coordinates: [
[
[2.2935, 48.8574], // bottom-left
[2.2955, 48.8574], // bottom-right
[2.2955, 48.8594], // top-right
[2.2935, 48.8594], // top-left
],
],
},
};
GeoJsonLayerOptions
The options to set on this layer.
const geoJsonOptions = {
filled: false,
units: 'pixels'
};
// ...
mapweave.addLayer(
new GeoJsonLayer({
data: geoJsonData,
options: geoJsonOptions
}),
);
Properties
Set to true to fill the Polygon, MultiPolygon, Point and MultiPoint features with the color set in color
.
Sets the units used for border.width
, width
and radius
.
A reference to the
data
object it was most recently passed.