1.0.13 • Published 5 years ago

@geonet/leaflet-wmgs v1.0.13

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

geonet-leaflet-wmgs

Leaflet.WMGS plugin (Web Map GeoJSON Service)

install

npm i -S @geonet/leaflet-wmgs

Usage

const wmgs = new L.WMGS( {
	crs: L.CRS.EPSG4326,
	url: 'http://localhost:3000/wmgs',
	// requestPerCell: false,
	// filterTimeRange: {},
	defaultStyle: {
		color: 'red'
	},
	query: {},
	// onCreateCell: ( bounds, coords ) => {},
	// onCellEnter: ( bounds, coords ) => {},
	// onCellLeave: ( bounds, coords ) => {},
	pointToLayer: ( feature, latlng ) => {
		return L.circleMarker( latlng, {
			radius: 8,
			fillColor: '#ff7800',
			color: '#000',
			weight: 1,
			opacity: 1,
			fillOpacity: 0.4
		} );
	},
	onEachFeature: ( geojson, layer ) => {
		// Render the feature
		layer.feature.properties.type = 'AOI';
		this.drawLayer.addLayer( layer );
	}
} );

wmgs.addTo( map );

map.on( L.Draw.Event.CREATED, e => wmgs.createFeature( e ) );
map.on( L.Draw.Event.EDITED, e => wmgs.updateFeatures( e ) );
map.on( L.Draw.Event.DELETED, e => wmgs.deleteFeatures( e ) );

Options

optiondefaultrequiredtypedescription
urltrueStringURL for WMGS API
CRSL.CRS.EPSG4326falseStringCoordinate Reference Systems (default: equirectangular projection)
requestPerCellfalsefalseBooleanRequest GeoJSON one cell at a time, or group all cells together
filterTimeRange{ from: 0, to: 0 }falseObjectFilter objects based on time range
defaultStyle{ color: 'blue', opacity: 1, fillOpacity: 0.4 }falseObjectDefault polygon styling
query{}falseObjectDefine query parameters to filter all responses by
select{ type: true, properties: true, geometry: true }falseObjectDefine parameters to select from DB (type, properties, and geometry must be defined to properly render GeoJSON)
onCreateCellfalseFunctionCalled when a new cell is created
onCellEnterfalseFunctionCalled when an existing cell is entered
onCellLeavefalseFunctionCalled when an existing cell is exited
pointToLayerfalseFunctionFunction that will be used for creating layers for GeoJSON Points.
onEachFeaturefalseFunctionFunction used to add GeoJSON to the map or allows for inspection of GeoJSON Features.

Methods

methodparamsreturnsdescription
fetchObject (request options){Promise<*>}Used to request the WMGS server
customRequestObject (request options){Promise<*>}Allows user to make custom defined request to the WMGS server
getTypesArrayGet the types of Features defined in the WMGS server
getFeaturesbounds (L.latLng object)Object (FeatureCollection)Method used by module to request GeoJSON from WMGS. Method will pass all retrieved layers into onEachFeature
createFeatureLayerFetch responseAdd a WMGS Feature
updateFeaturesLayer[]Fetch responseUpdate WMGS Features
deleteFeaturesLayer[]Fetch responseDelete WMGS Features
timeFromObjectIdObjectIDDateConverts an ObjectID into a Date
objectIdToTimeDateObjectIDConverts a Date into an ObjectID
1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago