我试图在路径中添加一个变量来映射层。
mypath='MyApp'
var Finals = L.tileLayer.wms("http://localhost:8080/geoserver/'+mypath+'/wms", {
layers: 'MyApp:finalVector',
format: 'image/png',
transparent: true,
version: '1.1.0',
attribution: "myattribution"
});如何在Finals变量中添加mypath变量。
添加之后,它的作用应该如下所示
var Finals = L.tileLayer.wms("http://localhost:8080/geoserver/MyApp/wms", {
layers: 'MyApp:finalVector',
format: 'image/png',
transparent: true,
version: '1.1.0',
attribution: "myattribution"
});发布于 2017-10-24 04:12:51
mypath='MyApp'
var Finals = L.tileLayer.wms("http://localhost:8080/geoserver/" + mypath + "/wms", {
layers: 'MyApp:finalVector',
format: 'image/png',
transparent: true,
version: '1.1.0',
attribution: "myattribution"
});发布于 2017-10-24 04:17:24
可以使用模板文本将变量传递给字符串。
var Finals = L.tileLayer.wms(`http://localhost:8080/geoserver/${mypath}/wms`, {
layers: 'MyApp:finalVector',
format: 'image/png',
transparent: true,
version: '1.1.0',
attribution: "myattribution"
});https://stackoverflow.com/questions/46902043
复制相似问题