Skip to content

Commit a69e212

Browse files
authored
Merge pull request #1 from trojan-ann/master
更新最新的iclient代码
2 parents 6875571 + 9d4a27b commit a69e212

File tree

353 files changed

+45529
-4622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

353 files changed

+45529
-4622
lines changed

examples/GraphicsEvents.html

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Graphic图层符号绘制</title>
6+
<style type="text/css">
7+
body{
8+
margin: 0;
9+
overflow: hidden;
10+
background: #fff;
11+
}
12+
#map{
13+
position: relative;
14+
height: 500px;
15+
border:1px solid #3473b7;
16+
}
17+
#toolbar {
18+
position: relative;
19+
padding-top: 5px;
20+
padding-bottom: 10px;
21+
}
22+
</style>
23+
24+
<script type="text/javascript">
25+
var map,layer, graphicLayer, symbolinfo, selectGraphic, popup = null,img,imageWidth=32, imagePaths = ['./images/marker_blue.png','./images/marker_red.png'],imageIdx = 0,
26+
host = document.location.toString().match(/file:\/\//) ? "http://support.supermap.com.cn:8090" : 'http://' + document.location.host;
27+
url = host + "/iserver/services/map-china400/rest/maps/China";
28+
function init()
29+
{
30+
31+
if(!document.createElement("canvas").getContext){
32+
alert("您的浏览器不支持Canvas,请先升级");
33+
return;
34+
}
35+
map = new SuperMap.Map("map",{controls:[
36+
new SuperMap.Control.Zoom(),
37+
new SuperMap.Control.Navigation() ,
38+
new SuperMap.Control.LayerSwitcher()
39+
]});
40+
layer= new SuperMap.Layer.TiledDynamicRESTLayer("World", url, null,{maxResolution:"auto"});
41+
layer.events.on({"layerInitialized":addLayer});
42+
graphicLayer = new SuperMap.Layer.Graphics("Graphic Layer", null, {hitDetection: true, useCanvasEvent: false});
43+
44+
selectGraphic = new SuperMap.Control.SelectGraphic(graphicLayer, {
45+
onSelect: onGraphicSelect,
46+
hover: false,
47+
onUnSelect: onUnGraphicSelect
48+
});
49+
}
50+
51+
function onGraphicSelect(result, evt) {
52+
var image = graphicLayer.style.image;
53+
54+
var pixel = map.getPixelFromLonLat(new SuperMap.LonLat(result.geometry.x, result.geometry.y));
55+
var evtPixel = evt.xy;
56+
//点击点与中心点的角度
57+
var angle = (Math.atan2(evtPixel.y - pixel.y, evtPixel.x - pixel.x))/Math.PI*180;
58+
angle = angle > 0 ? angle : 360+angle;
59+
//确定扇叶
60+
var index = Math.ceil(angle/(image.angle + image.spaceAngle));
61+
addPopup(result, evt, index);
62+
}
63+
function onUnGraphicSelect(evt) {
64+
//alert(2);
65+
}
66+
67+
function addPopup(feature, evt, index) {
68+
if(!!popup) {
69+
map.removePopup(popup);
70+
}
71+
selectedFeature = feature;
72+
var lonlat = new SuperMap.LonLat(feature.geometry.x,feature.geometry.y);
73+
var contentHTML = "<div style='font-size:.8em; opacity: 0.8; overflow-y:hidden;'>" +
74+
"<span style='font-weight: bold; font-size: 12px;'>要素ID: " + feature.id + "</span><br>";
75+
if(symbolinfo instanceof SuperMap.Style.Clover){
76+
contentHTML +="<span style='font-weight: bold; font-size: 12px;'>叶数索引: " + index + "</span><br>";
77+
lonlat = map.getLonLatFromPixel(evt.xy);
78+
}else{
79+
lonlat = new SuperMap.LonLat(feature.geometry.x,feature.geometry.y);
80+
}
81+
contentHTML +="</div>"
82+
//初始化一个弹出窗口,当某个地图要素被选中时会弹出此窗口,用来显示选中地图要素的属性信息
83+
popup = new SuperMap.Popup.FramedCloud("chicken",
84+
lonlat,
85+
null,
86+
contentHTML,
87+
null,
88+
true);
89+
feature.popup = popup;
90+
map.addPopup(popup);
91+
92+
}
93+
94+
function addLayer(){
95+
map.addLayers([layer,graphicLayer]);
96+
//显示地图范围
97+
map.setCenter(new SuperMap.LonLat(0, 0), 1);
98+
99+
map.addControl(selectGraphic);
100+
selectGraphic.activate();
101+
addClover();
102+
}
103+
104+
//symbol相关属性 填充色、边框颜色、半径、
105+
var fillColors = 'rgba(255,153,0,1)';
106+
var strokeColors = 'rgba(255,204,0,1)';
107+
var radius = 9;
108+
109+
110+
var e = 10000000;
111+
function addClover() {
112+
symbolinfo = new SuperMap.Style.Clover({
113+
radius: radius,
114+
fill: new SuperMap.Style.Fill({
115+
color: fillColors
116+
}),
117+
stroke: new SuperMap.Style.Stroke({
118+
color: strokeColors
119+
})
120+
});
121+
loadData();
122+
}
123+
function addData(img)
124+
{
125+
if(img.complete ){
126+
loadData();
127+
}else{
128+
img.onload = function() {
129+
loadData();
130+
}
131+
}
132+
}
133+
134+
function loadData() {
135+
if(!!popup) {
136+
map.removePopup(popup);
137+
}
138+
graphicLayer.removeAllGraphics();
139+
var total = document.getElementById("total").value;
140+
graphicLayer.style = {
141+
image: symbolinfo
142+
};
143+
var points = [];
144+
for(var i = 0; i<total; i++){
145+
var point= new SuperMap.Geometry.Point(2 * e * Math.random() - e, 2 * e * Math.random() - e);
146+
var pointVector = new SuperMap.Graphic(point);
147+
//pointVector.style = ;
148+
points.push(pointVector)
149+
}
150+
graphicLayer.addGraphics(points);
151+
}
152+
153+
function redraw() {
154+
var idx = (++imageIdx)%2;
155+
img = new Image();
156+
img.src = imagePaths[idx];
157+
symbolinfo = new SuperMap.Style.Image({
158+
img:img,
159+
anchor:[16,16]
160+
});
161+
graphicLayer.style = {
162+
image: symbolinfo
163+
};
164+
if(img.complete ){
165+
graphicLayer.redraw();
166+
}else{
167+
img.onload = function() {
168+
graphicLayer.redraw();
169+
}
170+
}
171+
172+
}
173+
174+
//移除数据
175+
function removeData()
176+
{
177+
if(!!popup) {
178+
map.removePopup(popup);
179+
}
180+
graphicLayer.removeAllGraphics();
181+
graphicLayer.refresh();
182+
}
183+
function plus() {
184+
var idx = (++imageIdx)%2;
185+
img = new Image();
186+
imageWidth +=10;
187+
img.src = imagePaths[idx];
188+
symbolinfo = new SuperMap.Style.Image({
189+
img:img,
190+
anchor:[imageWidth/2,imageWidth/2]
191+
});
192+
graphicLayer.style = {
193+
image: symbolinfo,
194+
graphicHeight:imageWidth,
195+
graphicWidth:imageWidth
196+
};
197+
if(img.complete ){
198+
graphicLayer.redraw();
199+
}else{
200+
img.onload = function() {
201+
graphicLayer.redraw();
202+
}
203+
}
204+
}
205+
function minus() {
206+
var idx = (++imageIdx)%2;
207+
img = new Image();
208+
imageWidth -=10;
209+
if(imageWidth < 5){
210+
imageWidth = 5;
211+
}
212+
img.src = imagePaths[idx];
213+
symbolinfo = new SuperMap.Style.Image({
214+
img:img,
215+
anchor:[imageWidth/2,imageWidth/2]
216+
});
217+
graphicLayer.style = {
218+
image: symbolinfo,
219+
graphicHeight:imageWidth,
220+
graphicWidth:imageWidth
221+
};
222+
if(img.complete ){
223+
graphicLayer.redraw();
224+
}else{
225+
img.onload = function() {
226+
graphicLayer.redraw();
227+
}
228+
}
229+
}
230+
</script>
231+
</head>
232+
<body onload="init()" >
233+
<div id="toolbar">
234+
<input id="total" type="text" style="width: 100px" value="100000">
235+
<input type="button" class="btn" style="margin-bottom: 10px" value="开始绘制" onclick="addClover()">
236+
<input type="button" class="btn" style="margin-bottom: 10px" value="切换图标并重绘" onclick="redraw()">
237+
<input type="button" class="btn" style="margin-bottom: 10px" value="+" onclick="plus()">
238+
<input type="button" class="btn" style="margin-bottom: 10px" value="-" onclick="minus()">
239+
<input type="button" class="btn" style="margin-bottom: 10px" value="移除" onclick="removeData()">
240+
241+
</div>
242+
<div id="map"></div>
243+
<script src = '../libs/SuperMap.Include.js'></script>
244+
</body>
245+
</html>

examples/aMap.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
themeParameters = new SuperMap.REST.ThemeParameters({
6363
themes: [themeDotDensity],
6464
datasetNames: ["Countries"],
65-
dataSourceNames: ["World"]
65+
dataSourceNames: ["World"],
66+
types:['REGION']
6667
});
6768
//向iserver发送请求
6869
themeService.processAsync(themeParameters);

examples/animatorMigrate.html

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,32 @@
2525
<script src='../libs/SuperMap.Include.js'></script>
2626
<script type="text" id="cartocssStr">
2727
@color:#111;
28-
#World_Continent_txt__China400::hover{
28+
#World_Continent_txt___China::hover{
2929
text-fill:#0f0;
3030
}
31-
#World_Division__China400{
31+
#World_Division_pl___China{
3232
polygon-fill:#123;
3333
::click{
3434
polygon-fill:#123;
3535
}
3636
}
37-
#World_Continent__China400{
37+
#World_Continent_pl___China{
3838
polygon-fill:#000002;
39+
line-width:1;
3940
line-color:#888;
4041
::hover[featureID=73]{
4142
polygon-fill:#f00;
4243
}
4344
}
44-
#China_Capital_P__China400 [zoom>4] {
45+
#China_Capital_Pt___China [zoom>4] {
4546
point-file:url("../examples/images/marker2.png");
4647
}
47-
#China_Province_R__China400{
48+
#China_Province_pl___China{
4849
polygon-fill:#555;
4950
}
51+
#China_Boundary_A___China{
52+
line-color:#000000;
53+
}
5054
</script>
5155
<script type="text/javascript">
5256
var map, layer,animatorVector,vectorLayer,url2, host = document.location.toString().match(/file:\/\//) ? "http://localhost:8090" : 'http://' + document.location.host;
@@ -175,12 +179,11 @@
175179
//初始化图层
176180
var cartoCssStr=document.getElementById("cartocssStr");
177181
var cartoCss=cartoCssStr.text;
178-
var layerNames=["World_Division@China400","World_Continent@China400",
179-
"China_Province_R@China400","China_island_R@China400",
180-
"China_Provinces_L@China400","China_Capital_P@China400",
181-
"China_BeiJing@China400"].join(",");
182+
var layerNames=["World_Division_pl@China","World_Continent_pl@China",
183+
"China_Province_pl@China","China_Island@China",
184+
"China_Capital_Pt@China", "China_Boundary_A"].join(",");
182185
layerNames="["+layerNames+"]";
183-
layer = new SuperMap.Layer.TiledVectorLayer("China", url,{cacheEnabled:true,layerNames:layerNames},{useLocalStorage:true,cartoCss:cartoCss});
186+
layer = new SuperMap.Layer.TiledVectorLayer("China", url,{cacheEnabled:true, layerNames: layerNames},{useLocalStorage:true, cartoCSS: cartoCss});
184187
layer.events.on({"layerInitialized": addLayer});
185188

186189
}

examples/animatorTrain.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
@provinceLineColor:rgb(180,0,0);
3737

3838

39-
#China_Railway_L___China400::a{
39+
#China_Railway_L___China::a{
4040

4141
/*每一段的长度为15px,间隔也是15px*/
4242
line-color:@railwayColora;
4343
line-width:2.5;
4444
}
45-
#China_Railway_L___China400::b{
45+
#China_Railway_L___China::b{
4646

4747
/*每一段的长度为15px,间隔也是15px*/
4848
line-dasharray:18,18;
@@ -51,19 +51,19 @@
5151
}
5252
/*底下的地图背景图层*/
5353

54-
#World_Division___China400{
54+
#World_Division_pl___China{
5555
polygon-fill:@waterColor;
5656
}
5757

5858
/*中国除外的其他国家的图层*/
5959

60-
#World_Continent___China400{
60+
#World_Continent_pl___China{
6161
polygon-fill:@continentColor;
6262
line-width:1;
6363
line-color:rgb(180,180,180);
6464
}
6565

66-
#World_Division___China400{
66+
#World_Division_pl___China{
6767
polygon-fill:@waterColor;
6868
}
6969
</script>
@@ -104,10 +104,9 @@
104104
//初始化图层
105105
var cartoCssStr=document.getElementById("cartocssStr");
106106
var cartoCss=cartoCssStr.text;
107-
var layerNames=["World_Division@China400","World_Continent@China400",
108-
"China_Province_R@China400","China_island_R@China400",
109-
"China_Provinces_L@China400","China_Capital_P@China400",
110-
"China_BeiJing@China400"].join(",");
107+
var layerNames=["World_Division_pl@China","World_Continent_pl@China",
108+
"China_Province_pl@China","China_Island@China",
109+
"China_Capital_Pt@China", "China_Boundary_A"].join(",");
111110
layerNames="["+layerNames+"]";
112111
layer = new SuperMap.Layer.TiledVectorLayer("China", url,{cacheEnabled:true,layerNames:layerNames},{useLocalStorage:true,cartoCss:cartoCss});
113112
layer.events.on({"layerInitialized": addLayer});

examples/arcGIS93Rest.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@
208208
});
209209
//设置专题图参数
210210
themeParameters = new SuperMap.REST.ThemeParameters({
211-
datasetNames: ["China_Province_R"],
212-
dataSourceNames: ["China400"],
213-
themes: [themeUnique]
211+
datasetNames: ["China_Province_pg"],
212+
dataSourceNames: ["China"],
213+
themes: [themeUnique],
214+
types:['REGION']
214215
});
215216
//向iserver发送请求
216217
themeService.processAsync(themeParameters);

examples/baidu.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@
7070
}),
7171
themeParameters = new SuperMap.REST.ThemeParameters({
7272
themes: [themeGraduatedSymbol],
73-
datasetNames: ["China_Province_R"],
74-
dataSourceNames: ["China400"]
73+
datasetNames: ["China_Province_pg"],
74+
dataSourceNames: ["China"],
75+
types:['REGION']
7576
});
7677
//向iserver发送请求
7778
themeService.processAsync(themeParameters);

0 commit comments

Comments
 (0)