I'm having problems showing leaflet map in a b

2019-09-06 12:03发布

问题:

I'm trying to put a leaflet map on a bootstrap tab, but it's not working. Not showing at all or missing tiles and in the wrong position .

Does anyone have an idea how to fix that?

This is an example of the problem: missing tiles

This is my code: https://gist.github.com/h3kr/991ac0ee5a88d0cecba27e91c886675e

回答1:

You forgot to include the CSS file for Leaflet.

Let me quote the Leaflet docs:

The latest stable Leaflet release is hosted on a CDN — to start using it straight away, place this in the head of your HTML code:

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.2/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.2/dist/leaflet.js"></script>