首页 / 浏览问题 / WebGIS / 问题详情
给echarts图层绑定弹出窗口
55EXP 2022年07月15日

想给Echars生成的点图层绑定弹出窗口,但是失败了,代码如下(leaflet实现)

 layer2=L.supermap.echartsLayer(option)
                       

 layer2.bindPopup('Hi There!').addTo(map);
                     

显示报错 “坐标需要被设置”,有没有解决办法绑定弹出层,我不太想用echarts的提示框组件

1个回答

您好,Popup如果绑定在图层上需要绑定在有坐标属性的图层上,

http://support.supermap.com.cn:8090/iserver/iClient/forJavaScript/examples/leaflet/editor.html#02_editFeatures

像echartsLayer或者L.TileLayer这种瓦片的图层没有坐标,popup不知道显示在哪里所以报错没法加。

如果想要这种情况加的话,您可以指定坐标然后弹开它的方式添加。

如:            infoWin = L.popup({maxWidth: 400})
                .setLatLng(map.getCenter())
                .setContent(innerHTML)
                .openOn(map);

参考:http://support.supermap.com.cn:8090/iserver/iClient/forJavaScript/examples/leaflet/editor.html#01_mapService

希望可以帮助到您。

9,653EXP 2022年07月15日
好的谢谢了
...