javascript - Angular 2 中的 Leaflet + Google - 瓷砖顺序错误

标签 javascript angular google-maps typescript leaflet

我正在 Angular 2 中使用 Leaflet 和 Google,但遇到了一个问题 - 无法正确渲染 Tilemill 图 block - 它们以某种奇怪的顺序出现。

这是我得到的: enter image description here

所以,并不是所有的部分都在那里,它们现在是混合的

这是我的代码

map.component.ts

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

@Component({
  selector: 'app-map',
  templateUrl: './map.component.html',
  styleUrls: ['./map.component.css'],
  encapsulation: ViewEncapsulation.None

})
export class MapComponent implements OnInit {
  googleStreets = L.tileLayer('http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',{
    maxZoom: 10,
    subdomains:['mt0','mt1','mt2','mt3']
  });
  constructor() {}

ngOnInit() {
  let map = L.map("map", {
    center: [48.13, 11.57],
    zoom: 15,
    zoomControl: true,
    maxZoom: 10
  }).addLayer(this.googleStreets);
   map.invalidateSize();
  L.control.scale().addTo(map);
}}

此处为 HTML

<p>Map</p>
<div id="map"></div>

这是CSS

#map {
  position: absolute;
  height: 90%;
}

最佳答案

您的index.html 中需要此样式表

https://unpkg.com/leaflet@1.0.1/dist/leaflet.css

关于javascript - Angular 2 中的 Leaflet + Google - 瓷砖顺序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47294784/

相关文章:

javascript - 如何使用ace编辑器: input commands and complete options动态触发自动完成

jquery - 如何在 Angular 2/Typescript 中触发引导崩溃

c# - 打字机无法将嵌套的 c# 类正确转换为 TS 类

angular - 在 NgFor 循环中与 NgIf

android - Google Places API 自动完成仅获取城市列表

api - 使用 Google Maps API 获取旅行时间数据

google-maps - 如何在 HTML5 中的 Google map 上显示用户的位置?

javascript - 如何在 QWebEngine 中显示一个 QPixmap?

javascript - 在固定在顶部之前,如何使粘性导航栏在英雄底部显示透明?

javascript - 在 html : sjcl. hash.sha512 中导入脚本未定义