Viglino / ol-ext

Cool extensions for Openlayers (ol) - animated clusters, CSS popup, Font Awesome symbol renderer, charts for statistical map (pie/bar), layer switcher, wikipedia layer, animations, canvas filters.
https://viglino.github.io/ol-ext/
Other
1.21k stars 457 forks source link

add legend in feature #1082

Open alissonrodrigo opened 5 days ago

alissonrodrigo commented 5 days ago

I would like to know how I can add the distance and area measurement feature to the "LineString" and "Polygon" controls in the example "https://viglino.github.io/ol-ext/examples/bar/map.control.editionbar. html" I would like to set these values ​​as caption and not tooltip. Thank you, sorry for anything but I'm new here.

Viglino commented 5 days ago

You have to get the interaction associated with the controls (2 and 3) and set the tooltip feature with the one of the draw:

// Add a tooltip
var tooltip = new ol.Overlay.Tooltip();
map.addOverlay(tooltip);

// Set drawing feature (interaction on control 2 and 3
[2,3].forEach(function(i) {
  // Drawline interaction
  var draw= editbar.getControls()[i].getInteraction()
  // Set feature on drawstart
  draw.on('drawstart', tooltip.setFeature.bind(tooltip));
  // Remove feature on finish
  draw.on(['change:active','drawend'], tooltip.removeFeature.bind(tooltip));
})
alissonrodrigo commented 5 days ago
tooltip

Is it possible to fix the measured value? instead of just a tooltip

Viglino commented 5 days ago

Use CSS:

.ol-popup.tooltips.black {
    transform: none !important;
    bottom: 0;
}
alissonrodrigo commented 5 days ago

I don't think I can explain it properly, so I'll attach an image. You can see that for each line there is fixed measurement dataimage

alissonrodrigo commented 1 day ago

Does anyone know how I can fix the values ​​on the screen?

Viglino commented 1 day ago

Try FixedPopup https://viglino.github.io/ol-ext/examples/popup/map.fixedpopup.html

alissonrodrigo commented 1 day ago

I don't intend to fix the popup, but rather a label with the distance fixed