简体   繁体   English

Angular-Leaflet-Directive-在技术上渲染地图,但未显示任何图块的问题。

[英]Angular-Leaflet-Directive - Issue where the map is technically rendering, but none of its tiles appear .

. . . because the tiles are absolutely positioned within parent containers whose heights are equal to zero. 因为图块绝对位于高度为零的父容器内。

Here is the directive: https://github.com/tombatossals/angular-leaflet-directive 这是指令: https : //github.com/tombatossals/angular-leaflet-directive

I'm uncertain as to the appropriate channel by which to seek assistance since I'm dealing with a relatively small library. 由于我正在处理一个相对较小的图书馆,因此我不确定寻求帮助的适当渠道。 I'm pretty sure I'm not doing anything wrong, since the gray "canvas" with zoom controls for the map is rendering and the map's tiles are being loaded (but without actually being displayed). 我很确定我没有做错任何事情,因为带有地图缩放控件的灰色“画布”正在呈现,并且地图的图块正在加载(但实际上并未显示)。 I can force the tiles to appear by assigning a height to their parent element, but obviously that's not how Leaflet is supposed to work. 我可以通过为其父元素分配高度来强制显示拼贴,但显然这不是Leaflet应该如何工作的。

I realize this may not be the best place to ask for help on this sort of thing, so I'm wondering whether, if nothing else, someone might know how I might best go about seeking assistance. 我意识到这可能不是寻求此类帮助的最佳地点,所以我想知道是否有人(如果没有别的话)可能知道我最好地寻求帮助。

This selector in my CSS was the problem: 我的CSS中的这个选择器就是问题所在:

img {
  max-height: 100%;
  max-width: 100%;
}

The solution was simply to allow images to render as they normally would within the leaflet map 's container: 解决方案是简单地允许图像如通常在传单地图的容器中那样呈现:

.leaflet-container img {
  max-height: none;
  max-width: none;
}

Hard to tell, without seeing any of your project's code. 很难说,没有看到您项目的任何代码。 But it sounds like you need to apply a height to you #map container element. 但这听起来像您需要对#map容器元素应用高度。 Check out one of the leaflet tutorials for possible css examples. 请查看其中一份传单教程,以获取可能的CSS示例。

Something like the following would work: 像下面这样的东西会起作用:

#map{ height: 600px; width: 100% }

or 要么

#map{
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}

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

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