Commit 63a83155 authored by Thomas Frion's avatar Thomas Frion

[FEAT|BUG] The coordinates are displayed

The bug is that the css to display nicely is not considered
parent f4a29270
.info{
background: #ffffff;
opacity: .7;
padding: 5px 10px;
border-radius: 2px;
}
......@@ -35,13 +35,12 @@ export class MapComponent implements OnInit {
JSON.parse(localStorage.getItem(environment.localStorage.unit))
);
this.marker = L.marker(this.getCoor(this.unit.geom));
this.marker.bindPopup("<b>" + this.unit.code + "</b> <br>" + this.unit.name).openPopup();
this.marker.bindPopup("<b>" + this.unit.name + "</b> (" + this.unit.code + ")");
//https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
this.tiles = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: this.attributions.osm + ' | ' + this.attributions.otm,
});
}
......@@ -97,6 +96,23 @@ export class MapComponent implements OnInit {
otm.addTo(this.map);
this.marker.addTo(this.map);
this.marker.openPopup();
// Coordinates
let info = L.control({position: 'bottomright'});
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
this.update();
return this._div;
};
info.update = function (lon, lat) {
this._div.innerHTML = ' Lat: ' + lat + 'Lon: '+ lon;
};
info.addTo(this.map);
this.map.addEventListener('mousemove', function(e){
info.update(e.latlng.lng, e.latlng.lat);
});
}
private getCoor(geom : string) : number[] {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment