使用Open和传单-侧边栏-v2,我将侧边栏添加到我的地图中,这是可行的。然而,我也需要在我的地图上添加另一层,这一层将勾勒出每个国家。我把坐标存储在'borders.json‘文件中。我试图使用D3.json导入边界坐标,然后使用L.geoJson将新层添加到地图中。
我目前收到以下错误消息:
Uncaught TypeError: t.getLayerStatesArray is not a function
这是我代码的相关部分。
var map = new ol.Map({
target: "map",
layers: [
new ol.layer.Tile({
source: new ol.source.OSM(),
view: new ol.View({
center: ol.proj.transform([7, 51.2], "EPSG:4326", "EPSG:3857"),
zoom: 3,
var sidebar = new ol.control.Sidebar({
element: "sidebar",
position: "left",
map.addControl(sidebar);
d3.json(("borders.json"), function (json){
function style(feature) {
return {
fillColor: "transparent",
weight: 1,
opacity: 0.4,
color: 'grey',
fillOpacity: 0.3