gis.map.testdata.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. gis.script.loadtestVectorLayerdata = function() {
  2. gis.script.loadtestSql();
  3. }
  4. gis.script.loadtestVectorLayerdata2 = function() {
  5. vectorLayer.removeAllFeatures();
  6. var point= new SuperMap.Geometry.Point(lon,lat);
  7. var pointFeature = new SuperMap.Feature.Vector(point);
  8. pointFeature.id="p1";
  9. pointFeature.styleMap=new SuperMap.StyleMap({
  10. "default":new SuperMap.Style({
  11. fillColor:"#ffcc33",
  12. strokeColor:"#ccff99",
  13. strokeWidth:2,
  14. graphicZIndex:1
  15. }),
  16. "select":{
  17. fillColor:"33eeff",
  18. strokeColor:"3366aa",
  19. graphicZIndex:2
  20. }
  21. });
  22. //console.log('pointFeature:',pointFeature);
  23. vectorLayer.addFeatures(pointFeature);
  24. var point1= new SuperMap.Geometry.Point(lon+0.5,lat+0.5);
  25. var pointFeature1 = new SuperMap.Feature.Vector(point1);
  26. pointFeature1.id="p2";
  27. pointFeature1.style={
  28. fillColor:"red",
  29. strokeColor:"yellow",
  30. pointRadius:7
  31. };
  32. vectorLayer.addFeatures(pointFeature1);
  33. var points1=[
  34. //new SuperMap.Geometry.Point(119,33),
  35. //new SuperMap.Geometry.Point(119,32)
  36. new SuperMap.Geometry.Point(lon,lat),
  37. new SuperMap.Geometry.Point(lon+0.5,lat+0.5)
  38. ];
  39. var line = new SuperMap.Geometry.LinearRing(points1);
  40. var lineVector = new SuperMap.Feature.Vector(line);
  41. lineVector.id="l1";
  42. lineVector.style={
  43. strokeColor: "#304DBE",
  44. strokeDashstyle:"dot",
  45. strokeWidth: 2,
  46. pointerEvents: "visiblePainted",
  47. fillColor: "#304DBE",
  48. fillOpacity: 0.8
  49. } ;
  50. vectorLayer.addFeatures(lineVector);
  51. gis.script.loadtestSql();
  52. //gis.script.loadtestTheme();
  53. }
  54. gis.script.loadtestMarkersLayerdata = function() {
  55. var data=[{type:"1",functionName:"showMarkerInfo",lon:lon+0.15,lat:lat+0.15,w:21,h:25},
  56. {type:"2",functionName:"showMarkerInfo",lon:lon+0.25,lat:lat+0.25,w:21,h:25},
  57. {type:"1",functionName:"showMarkerInfo",lon:lon+0.35,lat:lat+0.35,w:21,h:25}];
  58. $.each(data, function(i, item){
  59. //alert(i+","+JSON.stringify(item));
  60. //alert(contextPath);
  61. item.src=contextPath+'/images/markerbig_select.png';
  62. gis.script.addMarker(item);
  63. });
  64. gis.script.loadtestSql2();
  65. }
  66. gis.script.loadtestMarkersLayerdata2 = function() {
  67. var size = new SuperMap.Size(21,25);
  68. var offset = new SuperMap.Pixel(-(size.w/2), -size.h);
  69. var icon = new SuperMap.Icon('../images/markerbig_select.png', size, offset);
  70. //初始化标记覆盖物类
  71. //var marker = new SuperMap.Marker(new SuperMap.LonLat(23.6530190,37.9439259),icon);//Math.ceil(Math.random()*50)
  72. var marker = new SuperMap.Marker(new SuperMap.LonLat(lon+0.25,lat+0.25),icon);
  73. //添加覆盖物到标记图层
  74. markersLayer.addMarker(marker);
  75. //注册 click 事件,触发 mouseClickHandler()方法
  76. marker.events.on({"click":function(e) {
  77. //console.log('e:',e);
  78. //console.log('this:',this);
  79. //var popup = gis.anchored.popup(this.getLonLat(),{});
  80. gis.anchored.addPopup(map,popup);
  81. }});
  82. }
  83. gis.script.loadtestSql = function(){
  84. var fileterParam = new SuperMap.REST.FilterParameter({
  85. attributeFilter:"smid>1",
  86. //name:"市界@合并",
  87. name:"市界@合并#1",
  88. fields:["smid","name"]
  89. });
  90. var queryBySQLParams=new SuperMap.REST.QueryBySQLParameters({
  91. queryParams:[fileterParam]
  92. })
  93. var queryBySQLService = new SuperMap.REST.QueryBySQLService(gis.script.url, {eventListeners: {
  94. "processCompleted": function(e){
  95. var result=e.result;
  96. console.log('result:',e);
  97. if(result&&result.totalCount>0){
  98. var recordset=result.recordsets[0];
  99. //alert(recordset.datasetName)
  100. //alert(recordset.features.length);
  101. for(var k=0;k<recordset.features.length;k++){
  102. var feature = recordset.features[k];
  103. var centerLonLat=feature.geometry.getBounds().getCenterLonLat();
  104. //alert(centerLonLat.lon+"_"+centerLonLat.lat);
  105. //alert(JSON.stringify(feature.attributes));
  106. //var feature=new SuperMap.Feature.Vector();
  107. /*
  108. feature.style = {
  109. strokeColor: "#304DBE",
  110. strokeWidth: 2,
  111. pointerEvents: "visiblePainted",
  112. fillColor: "#304DBE",
  113. fillOpacity: 0.5
  114. };
  115. */
  116. feature.styleMap=new SuperMap.StyleMap({
  117. "default":new SuperMap.Style({
  118. strokeColor: "#304DBE",
  119. strokeWidth: 2,
  120. pointerEvents: "visiblePainted",
  121. fillColor: "#304DBE",
  122. fillOpacity: 0.5,
  123. graphicZIndex:1
  124. }),
  125. "select":{
  126. strokeColor: "#304DBE",
  127. strokeWidth: 2,
  128. pointerEvents: "visiblePainted",
  129. fillColor: "#304DBE",
  130. fillOpacity: 0.8,
  131. graphicZIndex:2
  132. }
  133. });
  134. vectorLayer.addFeatures(feature);
  135. break;
  136. }
  137. }
  138. },
  139. "processFailed": function(e){
  140. alert(e.error.errorMsg);
  141. //console.log('err:',e);
  142. }
  143. }
  144. });
  145. //alert(queryBySQLService);
  146. queryBySQLService.processAsync(queryBySQLParams);
  147. }
  148. gis.script.loadtestSql2 = function(){
  149. var fileterParam = new SuperMap.REST.FilterParameter({
  150. attributeFilter:"smid>0",
  151. name:"港口@合并#3",
  152. fields:["smid","name","类别"]
  153. });
  154. var queryBySQLParams=new SuperMap.REST.QueryBySQLParameters({
  155. queryParams:[fileterParam]
  156. })
  157. var queryBySQLService = new SuperMap.REST.QueryBySQLService(gis.script.url, {eventListeners: {
  158. "processCompleted": function(e){
  159. var result=e.result;
  160. //console.log('result:',e);
  161. if(result&&result.totalCount>0){
  162. var recordset=result.recordsets[0];
  163. //alert(recordset.datasetName)
  164. //alert(recordset.features.length);
  165. for(var k=0;k<recordset.features.length;k++){
  166. var feature = recordset.features[k];
  167. //alert(JSON.stringify(feature.attributes));
  168. //alert(feature.geometry.getBounds().getCenterLonLat())
  169. if(feature.attributes.name==""){
  170. continue;
  171. }
  172. var centerLonLat=feature.geometry.getBounds().getCenterLonLat();
  173. var item={type:"1",functionName:"showMarkerInfo",lon:centerLonLat.lon,lat:centerLonLat.lat,w:21,h:25};
  174. item.src='../images/markerbig_select.png';
  175. item.name=feature.attributes.name;
  176. gis.script.addMarker(item);
  177. //var feature=new SuperMap.Feature.Vector();
  178. /*
  179. feature.style = {
  180. strokeColor: "#304DBE",
  181. strokeWidth: 2,
  182. pointerEvents: "visiblePainted",
  183. fillColor: "#304DBE",
  184. fillOpacity: 0.5
  185. };
  186. feature.styleMap=new SuperMap.StyleMap({
  187. "default":new SuperMap.Style({
  188. strokeColor: "#304DBE",
  189. strokeWidth: 2,
  190. pointerEvents: "visiblePainted",
  191. fillColor: "#304DBE",
  192. fillOpacity: 0.5,
  193. graphicZIndex:1
  194. }),
  195. "select":{
  196. strokeColor: "#304DBE",
  197. strokeWidth: 2,
  198. pointerEvents: "visiblePainted",
  199. fillColor: "#304DBE",
  200. fillOpacity: 0.8,
  201. graphicZIndex:2
  202. }
  203. });
  204. vectorLayer.addFeatures(feature);
  205. */
  206. //break;
  207. }
  208. }
  209. },
  210. "processFailed": function(e){
  211. alert(e.error.errorMsg);
  212. //console.log('err:',e);
  213. }
  214. }
  215. });
  216. //alert(queryBySQLService);
  217. queryBySQLService.processAsync(queryBySQLParams);
  218. }
  219. gis.script.loadtestTheme = function(){
  220. //港口@合并#3
  221. var themeGraph = new SuperMap.REST.ThemeGraph();
  222. var themeParam = new SuperMap.REST.ThemeParameters({
  223. datasetNames:["港口"],
  224. dataSourceNames:["合并#3"],
  225. themes:[themeGraph]
  226. });
  227. var themeService = new SuperMap.REST.ThemeService(gis.script.url, {
  228. eventListeners: {
  229. "processCompleted": function(e){
  230. //console.log('result1:',e);
  231. },
  232. "processFailed": function(e){alert(e.error.errorMsg);}
  233. }
  234. });
  235. themeService.processAsync(themeParam);
  236. }
  237. gis.script.testUTFGrid = function() {
  238. utfgrid = new SuperMap.Layer.UTFGrid("UTFGridLayer", gis.script.url,
  239. {
  240. layerName: "市界@合并",
  241. utfTileSize: 256,
  242. pixcell: 8,
  243. isUseCache: true
  244. },
  245. {
  246. utfgridResolution: 8
  247. });
  248. layer.events.on({"layerInitialized": function(){
  249. try{
  250. map.addLayer(utfgrid);
  251. }catch (e) {
  252. // TODO: handle exception
  253. }
  254. }});
  255. control = new SuperMap.Control.UTFGrid({
  256. layers: [utfgrid],
  257. callback: function(infoLookup, loc, pixel) {
  258. //console.log('infoLookup',infoLookup);
  259. var info;
  260. for (var idx in infoLookup) {
  261. info = infoLookup[idx];
  262. if (info && info.data) {
  263. //console.log('info',info);
  264. alert(info.data.NAME)
  265. }
  266. }
  267. },
  268. handlerMode: "click"
  269. });
  270. map.addControl(control);
  271. }
  272. gis.script.testiframe= function() {
  273. //console.log("tabitem",tabitem);
  274. var iframearray=$("iframe");
  275. $.each(iframearray, function(i,documentObj){
  276. //var obj=$(documentObj);
  277. if(tabitem&&tabitem.menuurl&&documentObj.src){
  278. if(documentObj.src.indexOf(tabitem.menuurl)>=0){
  279. //alert(i+">>"+documentObj.src);
  280. var iframepage=documentObj;
  281. if(iframepage&&iframepage.contentWindow){
  282. alert(iframepage.src);
  283. }
  284. return false;
  285. }
  286. }
  287. });
  288. $(".triggle").find("a").click(function(){
  289. //console.log($(this).index());
  290. var imgs = $("#demo_boat>img");
  291. for(var i=0;i<imgs.length;i++)
  292. {
  293. imgs[i].className=i==$(this).index()?"block":"hide";
  294. }
  295. })
  296. }