P
P
Pavel2018-05-24 02:13:11
Angular
Pavel, 2018-05-24 02:13:11

Why doesn't Leaflet work in Angular6?

I create a new empty project, connect leaflet and there are no errors, but it also works crookedly.

import { Component, OnInit } from '@angular/core';
import * as L from 'leaflet';

@Component({
  selector: 'app-root',
  template: '<div id="map" style="width:1440px;height:800px;"></div>',
  styleUrls: ['../../node_modules/leaflet/dist/leaflet.css']
})
export class AppComponent {
  ngOnInit() {
    const map = L.map('map').setView([51.505, -0.09], 13);
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {}).addTo(map);
  }
}

Here's what happens:
5b05f41076d7b749099443.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question