Skip to content

Commit 6f19a86

Browse files
committed
优化例子
1 parent 30cb40e commit 6f19a86

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

examples/openlayers/02_getGridCellInfos.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@
5959
duration: 250
6060
}
6161
}));
62-
var map, baseUrl = (window.isLocal ? document.location.protocol + "//" + document.location.host : "http://support.supermap.com.cn:8090")+"/iserver/services/map-world/rest/maps/世界地图_Day",
63-
url = (window.isLocal ? document.location.protocol + "//" + document.location.host : "http://support.supermap.com.cn:8090")+"/iserver/services/data-world/rest/data";
62+
var map, baseUrl = (window.isLocal ? document.location.protocol + "//" + document.location.host : "http://support.supermap.com.cn:8090") + "/iserver/services/map-world/rest/maps/世界地图_Day",
63+
url = (window.isLocal ? document.location.protocol + "//" + document.location.host : "http://support.supermap.com.cn:8090") + "/iserver/services/data-world/rest/data";
6464
map = new ol.Map({
6565
target: 'map',
6666
controls: ol.control.defaults({attributionOptions: {collapsed: false}})
67-
.extend([new ol.supermap.control.Logo()]),
67+
.extend([new ol.supermap.control.Logo()]),
6868
view: new ol.View({
6969
center: [0, 0],
7070
zoom: 3,
@@ -75,19 +75,24 @@
7575
var layer = new ol.layer.Tile({
7676
source: new ol.source.TileSuperMapRest({
7777
url: baseUrl
78-
7978
}),
8079
projection: 'EPSG:4326'
8180
});
8281
map.addLayer(layer);
8382

8483
map.on("click", function (evt) {
84+
var x = evt.coordinate[0];
85+
var y = evt.coordinate[1];
86+
if (x < -180.0 || x > 180.0 || y < -90 || y > 90) {
87+
return;
88+
}
8589
var getGridCellInfosParam = new SuperMap.GetGridCellInfosParameters({
8690
dataSourceName: "World",
8791
datasetName: "WorldEarth",
88-
X: evt.coordinate[0],
89-
Y: evt.coordinate[1]
92+
X: x,
93+
Y: y
9094
});
95+
9196
new ol.supermap.GridCellInfosService(url).getGridCellInfos(getGridCellInfosParam, function (serviceResult) {
9297
if (!serviceResult.result) {
9398
return;

0 commit comments

Comments
 (0)