Leafletjs离线支持
我使用 leafletJS 使用 openstreet 瓷砖显示离线地图,并且工作正常。我们需要使用 atlast 工具来生成图块并且能够做到这一点。但是,如果生成的图块与来自服务的纬度和经度不匹配,则如何处理这种情况,然后在传单中显示标记,但背景地图图块未加载(我知道它不会匹配,因此不会显示:))但是在那里我可以通过什么方式/方法找出所提供的纬度和经度不在离线生成的地图图块的范围内或同步,以便我可以向最终用户显示有意义的消息,并相应地用户/管理员将采取行动?
Am using leafletJS for showing offline maps using openstreet tiles and its working fine. We need to use atlast tool to generate tiles and able to do that. But how to handle case that if generated tiles are not matching with latitude and longitude which are coming from services then in leaflet is showing markers but background map tiles are not loading (I know it wont match so its not showing :) ) but is there any way / approach which I can figure out that latitude and longitude provided are not in range or in sync of map tiles generated for offline so that I can show meaningful message to end users and accordingly user / admin will take actions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以想象三种方法:
如果您知道要生成的瓷砖(通常是在边界框中生成瓷砖),则可以进行硬码,并检查给定的坐标是否在内部或外部,添加标记或跳到坐标。
这个问题( feflet-feflet-tile loading-错误事件 - 错误事件)检测传单何时无法加载瓷砖(无论出于何种原因:不存在瓷砖,没有连接,...)。也许您可以使用该
tileerror
事件通知用户。您可以将坐标转换为其滑动的tilename等效物,并尝试从服务器 /存储中手动请求该瓷砖(例如,使用fetch-api)。转换过程在OpenStreetMap-Wiki上详细介绍( https://wiki.openstreetmap.org/wiki/slippy_map_map_tilenames#ecmascript_.28javascript.2factionscript.2c_etc..29 )
)
I can imagine three approaches to this:
If you know which tiles you are generating (often times you are generating tiles in a bounding-box) you could hardcode that bounding-box and check if the given coordinate is inside or outside before adding the marker or jumping to the coordinate.
This question (leaflet - tile loading - error event) details a way to detect when Leaflet can't load a tile (for whatever reason: tile does not exist, no connection, ...). Maybe you could inform the user using that
tileerror
event.You could convert the coordinate into its Slippy-Tilename equivalent and try to manually request that tile from your server / storage (for example using the Fetch-API). The conversion process is detailed (with code!) on the Openstreetmap-Wiki (https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29)