OpenLayers onmousedown加载图像 [英] OpenLayers onmousedown load image
问题描述
我正在查看openLayers的示例( http ://openlayers.org/zh-CN/v3.14.1/examples/custom-interactions.html?q = custom ),我想知道如何在鼠标悬停时加载如示例中的小图像.地图?我尝试了几件事,但无法解决.有什么想法吗?
I was looking at this example of openLayers ( http://openlayers.org/en/v3.14.1/examples/custom-interactions.html?q=custom ) and I was wondering how can I load a small image like the one in the example on mouse down on the map? I tried several things but couldn't figure it out. Any ideas?
谢谢!
推荐答案
您链接到的示例使用自定义交互在地图上拖动现有特征-此代码非常有用,我用它来研究如何在周围拖动标记我的地图.
The example you link to uses custom interactions to drag existing features around the map - this code is very useful and I used it to work out how to drag markers around my map.
但是,最简单的方法是首先添加标记,即使用地图的singleclick事件处理程序:
However, there is a simpler way to add the markers in the first place, which is to use the map's singleclick event handler:
map.on("singleclick", function(event) {
// Add icon here...
})
我在这里举了一个完整的例子,展示了我是如何做到的:
I've put a complete example here, showing how I did it:
http://www.freytag.org .uk/pages/2016/03/06/openlayers-addfeature.html
一旦完成,您可以使用OL3示例中的自定义交互方式,然后将这些标记拖动到地图上.
Once you've got that working, you can use the custom interactions in the OL3 example to then drag those markers around the map.
这篇关于OpenLayers onmousedown加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!