Skip to content

Commit f59d971

Browse files
修改leaflet示例中点击运行出现报错的例子。review by zhurch
1 parent 4673bc7 commit f59d971

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

examples/leaflet/01_layerService.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727
function layerService() {
2828
L.supermap.getLayersInfoService(url).getLayersInfo().on("complete", function (serviceResult) {
29-
if (!infowin) {
30-
infowin = L.popup({maxWidth: 400});
31-
}
32-
var innerHtml = "";
29+
var innerHTML = "";
3330
serviceResult.result.map(function (layer) {
34-
innerHtml += layer.name + "<br>";
31+
innerHTML += layer.name + "<br>";
3532
});
36-
infowin.setLatLng(map.getCenter()).setContent(innerHtml).openOn(map);
33+
infowin = L.popup({maxWidth: 400})
34+
.setLatLng(map.getCenter())
35+
.setContent(innerHTML)
36+
.openOn(map);
3737
});
3838
}
3939
</script>

examples/leaflet/01_mapService.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
L.supermap.mapService(url, {
2929
projection: "4326"
3030
}).getMapStatus().on("complete", function (serviceResult) {
31-
if (!infoWin) {
32-
infoWin = L.popup({maxWidth: 400});
33-
}
3431
var innerHTML = "(map信息太多,只打印一部分)" + "<br><br>";
3532
innerHTML += "地图名:" + JSON.stringify(serviceResult.result.name, null, 2) + "<br>";
3633
innerHTML += "中心点:" + JSON.stringify(serviceResult.result.center, null, 2) + "<br>";
3734
innerHTML += "Bounds:" + JSON.stringify(serviceResult.result.bounds, null, 2) + "<br>";
38-
infoWin.setLatLng(map.getCenter()).setContent(innerHTML).openOn(map);
35+
infoWin = L.popup({maxWidth: 400})
36+
.setLatLng(map.getCenter())
37+
.setContent(innerHTML)
38+
.openOn(map);
3939
});
4040
}
4141
</script>

examples/leaflet/02_fieldsService.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
dataSourceName: "World",
3232
dataSetName: "continent_T"
3333
}).getFields().on("complete", function (serviceResult) {
34-
if (!infoWin) {
35-
infoWin = L.popup({maxWidth: 420});
36-
}
37-
infoWin.setLatLng(map.getCenter()).setContent(serviceResult.result.fieldNames.join(', ')).openOn(map);
34+
var innerHTML = serviceResult.result.fieldNames.join(', ');
35+
infoWin = L.popup({maxWidth: 420})
36+
.setLatLng(map.getCenter())
37+
.setContent(innerHTML)
38+
.openOn(map);
3839
});
3940
}
4041
</script>

0 commit comments

Comments
 (0)