Skip to content

Commit 81634d9

Browse files
修改地物编辑示例中的问题。review by zhurch
1 parent 7f61515 commit 81634d9

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed

examples/leaflet/02_editFeatures.html

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
<link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
77
<link rel="stylesheet" href="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.css">
88
</head>
9-
<body onload="init()"
10-
style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
9+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
1110
<div id="toolbar" style="height:44px; padding-top: 6px; text-align: right ">
1211
<input type="button" class="btn btn-default" value="添加地物" onclick="addMarker()"/>
1312
<input type="button" class="btn btn-default" value="提交添加" onclick="commit()"/>
@@ -23,18 +22,16 @@
2322
baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World",
2423
urlCapital = "http://support.supermap.com.cn:8090/iserver/services/data-world/rest/data/datasources/World/datasets/Capitals",
2524
url = "http://support.supermap.com.cn:8090/iserver/services/data-world/rest/data";
26-
function init() {
27-
map = L.map('map', {
28-
preferCanvas: true,
29-
crs: L.CRS.EPSG4326,
30-
center: {lon: 110, lat: 30},
31-
maxZoom: 18,
32-
zoom: 3
33-
});
34-
L.supermap.tiledMapLayer(baseUrl).addTo(map);
35-
featureGroup = L.featureGroup().addTo(map);
36-
initFeature();
37-
}
25+
map = L.map('map', {
26+
preferCanvas: true,
27+
crs: L.CRS.EPSG4326,
28+
center: {lon: 110, lat: 30},
29+
maxZoom: 18,
30+
zoom: 3
31+
});
32+
L.supermap.tiledMapLayer(baseUrl).addTo(map);
33+
featureGroup = L.featureGroup().addTo(map);
34+
initFeature();
3835

3936
function initFeature() {
4037
var polygon = L.polygon([[10, 100], [10, 124], [40, 124], [40, 100], [10, 100]]);

examples/openlayers/02_editFeatures.html

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
77
<link href="http://cdn.bootcss.com/openlayers/4.0.1/ol.css" rel="stylesheet">
88
</head>
9-
<body onload="init()" style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
9+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
1010
<div id="toolbar" style="height:44px; padding-top: 6px; text-align: right ">
1111
<input type="button" class="btn btn-default" value="添加地物" onclick="addMarker()"/>
1212
<input type="button" class="btn btn-default" value="提交添加" onclick="commit()"/>
@@ -22,24 +22,23 @@
2222
baseUrl = "http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World",
2323
urlCapital = "http://support.supermap.com.cn:8090/iserver/services/data-world/rest/data/datasources/World/datasets/Capitals",
2424
url = "http://support.supermap.com.cn:8090/iserver/services/data-world/rest/data";
25-
function init() {
26-
map = new ol.Map({
27-
target: 'map',
28-
view: new ol.View({
29-
center: [50, 0],
30-
zoom: 3,
31-
projection: 'EPSG:4326'
32-
})
33-
});
34-
var layer = new ol.layer.Tile({
35-
source: new ol.supermap.TileSuperMapRest({
36-
url: baseUrl
37-
}),
25+
26+
map = new ol.Map({
27+
target: 'map',
28+
view: new ol.View({
29+
center: [50, 0],
30+
zoom: 3,
3831
projection: 'EPSG:4326'
39-
});
40-
map.addLayer(layer);
41-
initFeature();
42-
}
32+
})
33+
});
34+
var layer = new ol.layer.Tile({
35+
source: new ol.supermap.TileSuperMapRest({
36+
url: baseUrl
37+
}),
38+
projection: 'EPSG:4326'
39+
});
40+
map.addLayer(layer);
41+
initFeature();
4342

4443
function initFeature() {
4544
var polygon = new ol.geom.Polygon([[[118, 20], [120, 20], [120, 50], [-120, 50], [118, 20]]]);

0 commit comments

Comments
 (0)