import {useGeographic} from '../src/ol/proj.js'; import {Map, View, Feature, Overlay} from '../src/ol/index.js'; import {Point} from '../src/ol/geom.js'; import {Vector as VectorLayer, Tile as TileLayer} from '../src/ol/layer.js'; import {OSM, Vector as VectorSource} from '../src/ol/source.js'; import {Style, Circle, Fill} from '../src/ol/style.js'; useGeographic(); const place = [-110, 45]; const point = new Point(place); const map = new Map({ target: 'map', view: new View({ center: place, zoom: 8 }), layers: [ new TileLayer({ source: new OSM() }), new VectorLayer({ source: new VectorSource({ features: [ new Feature(point) ] }), style: new Style({ image: new Circle({ radius: 9, fill: new Fill({color: 'red'}) }) }) }) ] }); const element = document.getElementById('popup'); const popup = new Overlay({ element: element, positioning: 'bottom-center', stopEvent: false, offset: [0, -10] }); map.addOverlay(popup); function formatCoordinate(coordinate) { return `
| lon | ${coordinate[0].toFixed(2)} |
|---|---|
| lat | ${coordinate[1].toFixed(2)} |