简体   繁体   English

如何在传单中添加未引用的图像作为覆盖

[英]How to add a non-referenced image as overlay in leaflet

I have a Leaflet map, with tileLayer and markers. 我有一个Leaflet地图,其中包含tileLayer和标记。 I would like to add an image overlay to add some effects and styling to the tiles. 我想添加图像叠加层,以向图块添加一些效果和样式。

L.imageOverlay is nice, but it requires bounds, whereas I would like to anchor the image to absolute pixels of the rendered map. L.imageOverlay很不错,但是它需要边界,而我想将图像锚定到渲染地图的绝对像素。 For example to have an effect that is continuous towards the zoom levels. 例如,具有朝着缩放级别连续的效果。

It should be possible to do it by getting the extent and redefining the bounds of the layer each time, but it is ridiculous, as these would need to be converted to absolute values internally. 可以通过获取范围并每次重新定义层的边界来做到这一点,但这是荒谬的,因为这些将需要在内部转换为绝对值。 Nevertheless, I couldn't find the way of doing it by reading the API. 尽管如此,我无法通过阅读API找到实现此目的的方法。

You can image things like a frame, like fading, etc... on top of the map. 您可以在地图顶部将诸如框架,渐变之类的东西成像。

You could use a control and a div to manipulate the image. 您可以使用控件和div来操纵图像。 Not sure if this helps. 不确定是否有帮助。

var legend2 = L.control({position: 'topleft'}); 
legend2.onAdd = function (map) {        
    var div = L.DomUtil.create('div', 'info legend2');
    div.innerHTML = '<img src="https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png" style="transform: matrix3d(-0.509677, 0.655299, 0, -0.000417152, 0.597349, 0.564009, 0, 0.000111701, 0, 0, 1, 0, 0, 0, 0, 1); ">';     
    return div;
};      
legend2.addTo(map);

Doing some reading as adding a watermark would be useful for us. 做一些阅读来添加水印对我们很有用。 The intro for the core Spin.js library that leaflet.spin.js calls on mentions this: leaflet.spin.js调用的核心Spin.js库的介绍提到了这一点:

The spin() method creates the necessary HTML elements and starts the animation. spin()方法创建必要的HTML元素并开始动画。 If a target element is passed as argument, the spinner is added as first child and horizontally and vertically centered. 如果将目标元素作为参数传递,则将微调器作为第一个子元素添加,并在水平和垂直方向居中。

So when this._spinner = new Spinner().spin(this._container); 所以当this._spinner = new Spinner().spin(this._container); is called for the layer that is loading, the layer size is determined in pixels. 对于要加载的图层调用,则图层大小以像素为单位确定。 It's fixed in the DOM, not in the leaflet layers. 它是在DOM中固定的,而不是在传单层中固定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM