Created
December 19, 2016 08:31
-
-
Save hijiangtao/1bcab3154afa08d1b5d97f7944216208 to your computer and use it in GitHub Desktop.
Part of Layers didn't display when the map was initialized but became normal when I resize the browser window?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Leaflet JS Bin</title> | |
</head> | |
<body> | |
<div id='map'></div> | |
<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> | |
<script> | |
// Remember to include either the Leaflet 0.7.3 or the Leaflet 1.0.0-beta1 library | |
var baseLayer = L.tileLayer( | |
'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png') | |
map = new L.map('map', { | |
center: L.latLng(39.914,116.396), | |
zoom: 12, | |
layers: baseLayer | |
}) | |
map.zoomControl.setPosition('topright'); | |
</script> | |
<style> | |
#map { | |
width:100vw; | |
height:100vh; | |
} | |
</style> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is caused by customized stylesheet order. I should put the style codes in front of JS codes, otherwise the map will not show correctly as the map container had been modified after the map was initialized. More details at Leaflet/Leaflet#5207