A control displaying rough x-axis distances, calculated for the center of the viewport.
For conformal projections (e.g. EPSG:3857, the default view projection in OpenLayers), the scale is valid for all direction
controls: ol.control.defaults().extend([new ol.control.ScaleLine({
className: 'petabp-scale-line ol-scale-line'
})]),
this.map = new ol.Map({
target: 'map',
interactions: ol.interaction.defaults({
mouseWheelZoom: false
}),
var drawMarkerPoints = new ol.interaction.Draw({
type: "Point",
source: this.markerSource
});
- Interaction that allows drawing geometries
- Layer source for tile data with URLs in a set XYZ format that are defined in a URL template. By default, this follows the widely-used Google grid where x 0 and y 0 are in the top left. Grids like TMS where x 0 and y 0 are in the bottom left can be used by using the {-y} placeholder in the URL template, so long as the source does not have a custom tile grid
var baseLayer;
if(isProduction) {
baseLayer = new ol.layer.Tile({
source: new ol.source.XYZ({
url: '/basemap/xyz/DOSM/Desktop/?z={z}&y={y}&x={x}'
})
});
- Layer source for tile data from WMS servers.
var buLayer = new ol.layer.Tile({
source: new ol.source.TileWMS({
serverType: 'geoserver',
url: wmsBaseUrl,
params: {
LAYERS: 'dsm:bu'
}
})
});
Subclasses:
- Provides a source of features for vector layers.
- Vector features provided by this source are suitable for editing.
this.ebSource = new ol.source.Vector();
var ebLayer = new ol.layer.Vector({
source: this.ebSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: "rgb(192,0,0)",
width: 2
})
})
});
- Format for reading and writing data in the GeoJSON format
mounted() {
this.gjFormat = new ol.format.GeoJSON({
featureProjection: 'EPSG:3857'
});
var feature = new ol.Feature({
geometry: new ol.geom.Polygon(polyCoords),
labelPoint: new ol.geom.Point(labelCoords),
name: 'My Polygon'
});
// get the polygon geometry
var poly = feature.getGeometry();
// Render the feature as a point using the coordinates from labelPoint
feature.setGeometryName('labelPoint');
// get the point geometry
var point = feature.getGeometry();
DRAW_POINTS(payload) {
// Draw the points on the map + set label
let { label, coordinates } = payload;
let newCurrentFeature = new ol.Feature(new ol.geom.Point(coordinates));
newCurrentFeature.set("text", label);
this.markerSource.addFeature(newCurrentFeature);
// Push the points to the submit object
this.PUSH_POINTS_TO_SUBMIT({label, coordinates});
},
//Transforms a coordinate from longitude/latitude to a different projection.
this.mapView = new ol.View({
center: ol.proj.fromLonLat([101.5183469, 3.0738379]),
zoom: 12,
minZoom: 11,
maxZoom: 19
});
Pull tiles from OSM, Bing, MapBox, Stamen, and any other XYZ source you can find.
Support OGC mapping services and untiled layers
Render vector data from GeoJSON, TopoJSON, KML, GML, Mapbox ventor tiles and other formats
Leverages Canvas 2D, WebGL, and all the latest greatness from HTML5.
Mobile support out of the box. Build lightweight custom profiles with just the components you need
Style your map controls with straight-forward CSS.
Hook into different levels of the API or use 3rd party libraries to customize and extend functionality
import Map from 'ol/Map';
var map = new Map({target: 'map'});
//dsl job-assignment.js
this.map = new ol.Map({
target: 'ol-map-eb',
layers: [baseLayer, ebLayer],
view: this.mapView
});
import View from 'ol/View';
map.setView(new View({
center: [0, 0],
zoom: 2
}));
//dsl job-assignment
this.map = new ol.Map({
target: 'ol-map-eb',
layers: [baseLayer, ebLayer],
view: this.mapView
});
this.gjFormat = new ol.format.GeoJSON({
featureProjection: 'EPSG:3857'
});
import OSM from 'ol/source/OSM';
var osmSource = OSM();
//dsl job-assignment
this.gjFormat = new ol.format.GeoJSON({
featureProjection: 'EPSG:3857'
});
3. Vector
- Renders vector data client-side
4. VectorTile
- Renders data that is provided as vector tiles
import TileLayer from 'ol/layer/Tile';
var osmLayer = new TileLayer({source: osmSource});
map.addLayer(osmLayer);
//dsl job-assignment - Tile
var baseLayer = new ol.layer.Tile({
source: new ol.source.XYZ({
url: basemapUrl
})
});
dsl job-assignment.js - Vector
// prepare eb layer
this.ebSource = new ol.source.Vector();
var ebLayer = new ol.layer.Vector({
source: this.ebSource,
style: function style(feature) {
return new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red',
width: 2
}),
fill: new ol.style.Fill({
color: [255, 0, 0, 0.1]
}),
text: new ol.style.Text({
font: '12px Arial',
fill: new ol.style.Fill({
color: 'black'
}),
text: feature.get('ngdbbp') || ''
})
});
}
});