I have tried for a while now to implement this leaflet tutorial using the ngx-leaflet
.
There is absolutely no clear documentation on how to implement a custom control or legend while following along with the tutorial.
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
this.update();
return this._div;
};
// method that we will use to update the control based on feature properties passed
info.update = function (props) {
this._div.innerHTML = '<h4>US Population Density</h4>' + (props ?
'<b>' + props.name + '</b><br />' + props.density + ' people / mi<sup>2</sup>'
: 'Hover over a state');
};
info.addTo(map);
Same goes for creating a legend.
Can any point me in the right direction to try and get this implemented in Angular 7 with ngx-leaflet lib?
import { control, featureGroup, geoJson, icon, latLng, LatLngExpression, Map, Marker, marker, popup, tileLayer } from 'leaflet';
onMapReady(map: Map) {
this.map = map;
// create info control
let info = control(
{
onAdd: map => {
}
}
)
info.addTo(map);
I get that you need to do something like this, but I don't want to add a circle or shape, but the custom control in the screenshot above as well as a legend.