问题
I am currently trying to update a map within a program from OpenLayers 3 to 6.3.1 in a WPF window. However im getting a problem where the mouse isn't passed through to the map.
The software I'm working on draws a bunch of edges over a roadmap (using Basemap) to show the capacity/utilization at a given time and calculates ideal routes and stuff (similar to Google Maps). When I click on the map it should show me the avaiable data to the nearest edge in a second window, the methods for this are already implemented, I just need to find out where I clicked.
The code im using looks lke this: (shortened some stuff I am probably not supposed to share)
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src ="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div id="map" class="map"></div>
<script src="index.js"></script>
</body>
</html>
index.js:
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import TileLayer from 'ol/layer/Tile.js';
import WMTS, {optionsFromCapabilities} from 'ol/source/WMTS.js';
import WMTSCapabilities from 'ol/format/WMTSCapabilities.js';
import {fromLonLat} from 'ol/proj';
import {toLonLat} from 'ol/proj';
import {defaults as defaultInteractions} from 'ol/interaction';
import 'ol-layerswitcher/src/ol-layerswitcher.css';
import LayerSwitcher from 'ol-layerswitcher';
var capabilitiesUrl = 'https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml';
var map = new Map({
layers: [],
target: 'map',
view: new View({
center: [0,0],
zoom: 2
}),
interactions: defaultInteractions()
});
var layerSwitcher = new LayerSwitcher();
map.addControl(layerSwitcher);
fetch(capabilitiesUrl).then(function(response) {
return response.text();
}).then(function(text) {
var result = new WMTSCapabilities().read(text);
var options = optionsFromCapabilities(result, {
layer: hidpiLayer,
matrixSet: 'google3857',
style: 'normal'
});
map.addLayer(new TileLayer({
title: 'Basemap',
type: 'base',
source: new WMTS((options))
}));
});
When i am runnign it in the browser it works without any problems, but within the WPF I can't drag the map around and it also doesn't register any mouseclicks. The dragging-around wouldn't be that bad, because i can still move around with the keyboard, but the clicks are essential to the functionality of the program.
I am guessing the problem lies somewhere in the communication between OpenLayers and WPF, but on OpenLayers 3 it works so I don't really know where to look.
I would be very grateful if someone was able to point me into the right direction, because I am out of ideas.
来源:https://stackoverflow.com/questions/61956563/mouse-passthrough-to-openlayers-using-wpf