Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Component.onCompleted: {
- iface.addItemToPluginsToolbar(pluginButton)
- pointHandler.registerHandler("species_plugin", (point, type, interactionType) => {
- if (interactionType === "clicked") {
- let tl = mapCanvas.mapSettings.screenToCoordinate(Qt.point(point.x - 4, point.y - 4))
- let br = mapCanvas.mapSettings.screenToCoordinate(Qt.point(point.x + 4, point.y + 4))
- let expression = "intersects(geom_from_wkt('POLYGON(("+tl.x+" "+tl.y+", "+br.x+" "+tl.y+", "+br.x+" "+br.y+", "+tl.x+" "+br.y+", "+tl.x+" "+tl.y+"))'), $geometry)"
- let it = LayerUtils.createFeatureIteratorFromExpression(qgisProject.mapLayersByName("plots")[0], expression)
- if (it.hasNext()) {
- const feature = it.next()
- console.log(feature.id)
- }
- }
- return false;
- });
- }
- Component.onDestruction: {
- pointHandler.deregisterHandler("species_plugin");
- }
Advertisement
Add Comment
Please, Sign In to add comment