我正在尝试使用 ClojureScript 中的 react-leaflet,但我对瓷砖的渲染方式有疑问:
- 某些图块不显示
- 在不同的城市有相邻显示的瓷砖
这是我的代码:
(ns carder-devcards.map
(:require [taoensso.timbre :as timbre]
[cljsjs.react-leaflet] ;; js/ReactLeaflet
)
(:require-macros [devcards.core :as dc :refer [defcard]]))
(defn build
([component props]
(build component props (array)))
([component props & children]
(.createElement js/React
component
(clj->js props)
(array children))))
(def tile-layer (partial build js/ReactLeaflet.TileLayer))
(def leaflet-map (partial build js/ReactLeaflet.Map))
(def marker (partial build js/ReactLeaflet.Marker))
(def popup (partial build js/ReactLeaflet.Popup))
(defcard simple-leaflet
(fn [state]
(let [{:keys [pos zoom] :as st} @state
tl (tile-layer {:url "http://{s}.tile.osm.org/{z}/{x}/{y}.png"
:attribution "© <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors"})
mk (marker {:position pos})]
(leaflet-map {:center pos :zoom zoom}
tl
mk
)))
{:pos [51.505, -0.09]
:zoom 13}
{:header true})
这是我在本地得到的结果。
注意:调整浏览器的大小似乎有效果,所以这也可能是一个 css 问题(?)。我试过包括以下内容但没有效果:
.leaflet-container {
height: 400px;
width: 100%;
}