Trying to use Leaflet in an Angular 6 component. Depending on how the css file is linked, the map shows ok or is messed up, there are missing tiles not in the right order, which
Doing this
@import url("path")
ex:
@import url("https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css")
or doig also
@import "bootstrap/dist/css/bootstrap.min.css"
Ok, here's what worked (thanks @Palsri, I read once more the blog post and the Angular styling guidelines and tried the following, which worked):
In a separate css file, import the leaflet css:
// map.component.css
@import url("../assets/lib/leaflet/leaflet.css");
.mapstyle {
width: 100%;
height:100%;
};
Then in the component, reference this css instead of the leaflet css as follows:
@Component({
templateUrl: "./map.component.html",
selector: "app-map",
styleUrls: ["./map.component.css"],
encapsulation: ViewEncapsulation.None
})
Here's the code in the html template:
<div id="map" class="mapstyle"></div>
One more thing: for the height % to work, you need to define the parents size, which I currently did in the index.html as follows:
<style>
html, body {
min-height: 100% !important;
height: 100%;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
</style>
Hope this helps.