1// test http://localhost/her/chi6/field.php?group=SMP 2 3/* 4Map Tiler 5 caption:'OS 2nd Edition (1899-1900)', 6source:'https://api.maptiler.com/tiles/uk-osgb10k1888/{zoom}/{x}/{y}.jpg?key=Hor717P9xYcWDPwv8jX5';, 7 8WMS 9 caption:'Dorset OS 1st Edition (1841-1888)', 10source:'https://mapseries-tilesets.s3.amazonaws.com/os/six-inch-dorset/{zoom}/{x}/{y}.png';, 11 12 13ESRI REST 14 caption:'Wiltshire Tithe Map (1838-1850)', 15source:'https://maps2.bristol.gov.uk/server1/services/base/1840s_tithe_wilts_128dpi/MapServer/WmsServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX={bbox}&CRS=CRS:84&WIDTH=1036&HEIGHT=398&LAYERS=0&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96';, 16 17website https://maps2.bristol.gov.uk/server1/rest/services/base/1840s_tithe_wilts_128dpi/MapServer 18*/ 19 20 21var geoBingMap,pinInfobox; 22var geoLayerSet=[]; 23 24function geoClassNullMap(options){ 25 var isNullMap=1; 26 var crs=27700; 27 var b,isIE8=0; 28 var startExtents=options.bounds,maxExtents=options.maxBounds,mousepos; 29 console.log('Using null map '+JSON.stringify(startExtents)); 30 this.disableNavigation=function(){} 31 this.enableNavigation=function(){} 32 this.getZoom=function(){8} 33 this.getCenter=function(){var a=this.getExtents();return [(a[0]+a[2])/2,(a[1]+a[3])/2];} 34 this.getExtents=function(){return startExtents;} 35 this.setZoom=function(z){} 36 this.setCenter=function(x,y){} 37 this.setCenterZoom=function(x,y,z){} 38 this.setExtents=function(x1,y1,x2,y2){} 39 this.mapViewChangeEnd=function(){} 40 this.addLayer=function(lid){} 41 this.zapLayer=function(lid){} 42 this.showLayer=function(lid){} 43 this.hideLayer=function(lid){} 44 this.clearLayer=function(lid){} 45 this.clearMap=function(){} 46 this.plotPoint=function(p,lid,fid,opts,label,icon,visible){} 47 this.plotPline=function(p,lid,fid,opts,visible,label){} 48 this.plotPolygon=function(p,lid,fid,opts,visible,label){} 49 this.pick=function(x,y){} 50} 51function geoClassAzureMap(options){ 52 var isNullMap=0; 53 var crs=27700; 54 var b,isIE8=0; 55 var startExtents=options.bounds,maxExtents=options.maxBounds,mousepos; 56 57 //startExtents=[-3.15855, 52.64962,-3.128926, 52.672]; 58 59 console.log('Using azure map '+JSON.stringify(startExtents)); 60 geoBingMap=map=new atlas.Map('mapsPanel',{ 61 bounds: startExtents, 62 style: 'satellite_road_labels', 63 authOptions: { 64 authType: 'subscriptionKey', 65 subscriptionKey:geoChiConfig.map.azureKey 66 } 67 }); 68 69 map.controls.add([ 70 //new atlas.control.PitchControl(), 71 //new atlas.control.CompassControl(), 72 new atlas.control.ZoomControl(), 73 //new atlas.control.StyleControl(), 74 new atlas.control.FullscreenControl(), 75 new atlas.control.ScaleControl(), 76 ],{position: 'bottom-right'}); 77 78 //Wait until the map resources are ready. 79 map.events.add('ready', function () { 80 console.log('azure map is ready'); 81 map.events.add('click',function(e){ 82 console.log('Map clicked at : '+e.position); 83 geoMapFrame.pick(e.shapes); 84 }); 85 map.events.add('move',function(e){ 86 geoBingViewChange(); 87 }); 88 map.events.add('moveend',geoBingViewChangeEnd); 89 // finaly call back to parent app that map is ready and it can proceed 90 geoInkMapClassReady(); 91 }); 92 this.disableNavigation=function(){} 93 this.enableNavigation=function(){} 94 this.getZoom=function(){var b=map.getCamera();return b.zoom;} 95 this.getCenter=function(){var b=map.getCamera();return b.center;} 96 this.getExtents=function(){var b=map.getCamera();return b.bounds;} 97 this.setZoom=function(z){map.setCamera({zoom:z});} 98 this.setCenter=function(x,y){map.setCamera({center:[x,y]});} 99 this.setCenterZoom=function(x,y,z){map.setCamera({center:[x,y],zoom:z});} 100 this.setExtents=function(x1,y1,x2,y2){map.setCamera({bounds:[x1,y1,x2,y2]});} 101 this.mapViewChangeEnd=function(){} 102 this.setMapType=function(type){ 103 map.setStyle({style:type}); 104 // grayscale_light, road_shaded_relief, blank, road, satellite_road_labels 105 // blank is for showing my layers with no background 106// alert('setmaptype'); 107 //map.setStyle({style:'road_shaded_relief' }); 108 //map.setStyle({style:'road' }); 109 //map.setStyle({style:'labels' }); 110 //Microsoft.Maps.MapTypeId.[Name] where [Name] can be any of the following values. 111 //ordnanceSurvey, road, aerial 112 //var t=Microsoft.Maps.MapTypeId.ordnanceSurvey;
113 //geoBingMap.setView({mapTypeId:t}); 114 } 115 this.addLayer=function(lid,type,style){ 116 if(geoLayerSet[lid]){this.showLayer(lid);return;} 117 var defaultStyle={icon:'sym/pinGreen16x16.png',iconSize:16,strokeColor:"#ff00ff",strokeOpacity:1,strokeWidth:3,fillColor:"#00ff00",fillOpacity:0.5,plineColor:"#ff0000",plineOpacity:1,plineWidth:2}; 118 if(style==undefined)style=defaultStyle; 119 if(style.icon==undefined)style.icon=defaultStyle.icon; 120 if(style.iconSize==undefined)style.iconSize=defaultStyle.iconSize; 121 if(style.strokeColor==undefined)style.strokeColor=defaultStyle.strokeColor; 122 if(style.strokeOpacity==undefined)style.strokeOpacity=defaultStyle.strokeOpacity; 123 if(style.strokeWidth==undefined)style.strokeWidth=defaultStyle.strokeWidth; 124 if(style.fillColor==undefined)style.fillColor=defaultStyle.fillColor; 125 if(style.fillOpacity==undefined)style.fillOpacity=defaultStyle.fillOpacity; 126 if(style.plineColor==undefined)style.plineColor=defaultStyle.plineColor; 127 if(style.plineOpacity==undefined)style.plineOpacity=defaultStyle.plineOpacity; 128 if(style.plineWidth==undefined)style.plineWidth=defaultStyle.plineWidth; 129 var geomSet={}; 130 // -------------- POLYGON 131 var polyDatSource=new atlas.source.DataSource(); 132 map.sources.add(polyDatSource); 133 var polyLayer=new atlas.layer.PolygonLayer(polyDatSource, null,{fillColor:style.fillColor,fillOpacity:style.fillOpacity}); 134 var polyBorder=new atlas.layer.LineLayer(polyDatSource,null,{strokeColor:style.strokeColor,strokeWidth:style.strokeWidth,strokeOpacity:style.strokeOpacity}); 135 map.layers.add([polyLayer,polyBorder]); 136 geomSet.polygon=[polyDatSource,polyLayer]; 137 map.events.add('mouseover',polyLayer, () => {map.getCanvasContainer().style.cursor = 'pointer';}); 138 map.events.add('mousemove',polyLayer, () => {map.getCanvasContainer().style.cursor = 'pointer';}); 139 map.events.add('mouseout', polyLayer, () => {map.getCanvasContainer().style.cursor = 'grab';}); 140 // -------------- LINE 141 var lineDatSource=new atlas.source.DataSource(); 142 map.sources.add(lineDatSource); 143 var lineLayer=new atlas.layer.LineLayer(lineDatSource,null,{strokeColor:style.strokeColor,strokeWidth:style.strokeWidth,strokeOpacity:style.strokeOpacity}); 144 map.layers.add(lineLayer); 145 geomSet.line=[lineDatSource,lineLayer]; 146 map.events.add('mouseover',lineLayer, () => {map.getCanvasContainer().style.cursor = 'pointer';}); 147 map.events.add('mousemove',lineLayer, () => {map.getCanvasContainer().style.cursor = 'pointer';}); 148 map.events.add('mouseout', lineLayer, () => {map.getCanvasContainer().style.cursor = 'grab';}); 149 // --------------- POINT 150 //var pointDatSource=new atlas.source.DataSource(); 151 var pointDatSource=new atlas.source.DataSource(null,{ 152 cluster: false, //Tell the data source to cluster point data - false by default 153 clusterRadius: 45, //The radius in pixels to cluster points together. 154 clusterMaxZoom: 10 //The maximum zoom level in which clustering occurs.If you zoom in more than this, all points are rendered as symbols. 155 }); 156 map.sources.add(pointDatSource); 157 var ic='sym/pinRed16x16.png'; 158 if(style&&style.icon)ic=style.icon; 159 map.imageSprite.add(lid,ic); 160 var pointLayer=new atlas.layer.SymbolLayer(pointDatSource,null,{ 161 textOptions: { 162 //Use the label property to populate the text for the symbols. 163 textField: ['get','label'], // ['get', 'label'] 164 color: '#000000', 165 size:16, // px 166 rotation:0, // degrees 167 haloWidth:2, 168 haloColor:'#FFFFFF', 169 haloBlur:2, 170 offset: [0,-2.6], 171 }, 172 iconOptions:{ 173 //Set the image option to the id of the custom icon that was loaded into the map resources. 174 // from style .. icon:'sym/mon.png',iconSize:10, 175 image: lid, 176 anchor: 'top-left', 177 offset: [-5, -30], 178 allowOverlap: true,ignorePlacement: true // these two show all points all time 179 } 180 }); 181 map.layers.add(pointLayer); 182 geomSet.point=[pointDatSource,pointLayer]; 183 map.events.add('mouseover',pointLayer, () => {map.getCanvasContainer().style.cursor = 'pointer';}); 184 map.events.add('mousemove',pointLayer, () => {map.getCanvasContainer().style.cursor = 'pointer';}); 185 map.events.add('mouseout', pointLayer, () => {map.getCanvasContainer().style.cursor = 'grab';}); 186 geoLayerSet[lid]=geomSet; 187 console.log( 'added layer '+lid+', type= '+type); 188 } 189 this.addLayerWMS=function(lid,url){ 190 this.addLayerTiled(lid,url,1,0,24,0); 191 } 192 this.addLayerWMTS=function(lid,url){ 193 this.addLayerTiled(lid,url,1,0,24,0); 194 } 195 this.addLayerTiled=function(lid,url,opacity,minZoom,maxZoom,visible){ 196 if(geoLayerSet[lid]){this.showLayer(lid);return;} 197 var ts,o=opacity; 198 if(o==undefined)o=1; 199 if(minZoom==undefined)minZoom=0; 200 if(maxZoom==undefined)maxZoom=24; 201 url=url.replace('{zoom}','{z}'); 202 url=url.replace('{bbox}','{bbox-epsg-3857}'); 203 url=url.replace('CRS=CRS:84','CRS=EPSG:3857'); 204 var ops={ 205 tileUrl: url, 206 opacity: opacity, 207 tileSize: 256, 208 minSourceZoom:minZoom, 209 maxSourceZoom:maxZoom 210 }; 211 var l=new atlas.layer.TileLayer(ops); 212 var ls=map.layers.userLayers; 213 var bottomLayer=ls[ls.length-1];
214 // next line optionaly make layer invisible before adding it to map 215 if(visible!=undefined&&!visible)var o=l.getOptions();o['visible']=false;l.setOptions(o); 216 map.layers.add(l,0); // 0 adds the layer at the bottom, can use { below: 'existingLayer' } 217 geoLayerSet[lid]=[url,l]; 218 console.log( 'added xyz tiled layer'+lid); 219 } 220 this.zapLayer=function(lid){console.log('zapLayer');} 221 this.showLayer=function(lid){ 222 var geomSet=geoLayerSet[lid]; 223 if(geomSet.polygon){ 224 this.hideShowLayer(geomSet.polygon[1],true); 225 this.hideShowLayer(geomSet.line[1],true); 226 this.hideShowLayer(geomSet.point[1],true); 227 }else{ 228 this.hideShowLayer(geomSet[1],true); 229 } 230 } 231 this.hideLayer=function(lid){ 232 var geomSet=geoLayerSet[lid]; 233 if(geomSet.polygon){ 234 this.hideShowLayer(geomSet.polygon[1],false); 235 this.hideShowLayer(geomSet.line[1],false); 236 this.hideShowLayer(geomSet.point[1],false); 237 }else{ 238 this.hideShowLayer(geomSet[1],false); 239 } 240 } 241 this.hideShowLayer=function(atlasLayer,visible){ 242 var o=atlasLayer.getOptions();o.visible=visible;atlasLayer.setOptions(o); 243 } 244 this.clearLayer=function(lid){ 245 var geomSet=geoLayerSet[lid]; 246 if(geomSet){ 247 if(geomSet.polygon){ 248 this.clearAtlasLayer(geomSet.polygon[1]); 249 this.clearAtlasLayer(geomSet.line[1]); 250 this.clearAtlasLayer(geomSet.point[1]); 251 } 252 else{ 253 this.clearAtlasLayer(geomSet[1]); 254 } 255 } 256 } 257 this.clearAtlasLayer=function(atlasLayer){ 258 var mapLayerId=atlasLayer.id; 259 var l=map.layers.getLayerById(mapLayerId); 260 if(l.getSource){ 261 var s=l.getSource(); 262 s.clear(); 263 }else{ 264 var o=l.getOptions();o['visible']=false;l.setOptions(o); 265 } 266 } 267 this.clearMap=function(){alert('clearMap');} 268 this.setLayerOpacity=function(lid,d){ 269 var o,l,geomSet=geoLayerSet[lid]; 270 if(geomSet.polygon){ 271 l=geomSet.polygon[1];o=l.getOptions();o.opacity=d;l.setOptions(o); 272 l=geomSet.line[1];o=l.getOptions();o.opacity=d;l.setOptions(o); 273 l=geomSet.point[1];o=l.getOptions();o.opacity=d;l.setOptions(o); 274 }else{ 275 l=geomSet[1];o=l.getOptions();o.opacity=d;l.setOptions(o); 276 } 277 } 278 this.plotPoint=function(p,lid,fid,opts,label,icon,visible){ 279 //Create a point feature, add a property to store a label for it, and add it to the data source. 280 var geomSet=geoLayerSet[lid]; 281 var ds=geomSet.point[0]; 282 ds.add(new atlas.data.Feature(new atlas.data.Point(p),{label:trim(label),inkLayerID:lid,inkFid:fid})); 283 } 284 this.plotPline=function(p,lid,fid,opts,visible,label){ 285 // p multiline string example [[[-73.972340, 40.743270], [-74.004420, 40.756800]]] array of points 286 //console.log(JSON.stringify(p)); 287 //var pl=new atlas.data.LineString(p[0]); 288 var pl=new atlas.data.MultiLineString(p); 289 var l=new atlas.Shape(new atlas.data.Feature(pl,{label:'',inkLayerID:lid,inkFid:fid})); // 290 var geomSet=geoLayerSet[lid]; 291 var ds=geomSet.line[0]; 292 ds.add(l); 293 } 294 this.plotPolygon=function(p,lid,fid,opts,visible,label){ 295 // p is array of arrays, first array is exterior 296 // eg [[[-73.98235, 40.76799],[-73.95785, 40.80044],[-73.94928, 40.7968],[-73.97317, 40.76437],[-73.98235, 40.76799]]] 297 var pl=new atlas.data.Polygon(p); 298 //var pl=new atlas.data.MultiPolygon(p); // keep this incase multipolgons later 299 var poly=new atlas.Shape(new atlas.data.Feature(pl,{label:'',inkLayerID:lid,inkFid:fid})); 300 var geomSet=geoLayerSet[lid]; 301 var ds=geomSet.polygon[0]; 302 ds.add(poly); 303 } 304 this.pick=function(shapes){ 305 var i,s,ps,lid,fid,hits={}; 306 for(i=0;i<shapes.length;i++){ 307 s=shapes[i]; 308 if(s.data){ 309 ps=s.data.properties; 310 lid=ps.inkLayerID; 311 fid=ps.inkFid; 312 if(!hits[lid])hits[lid]={'fids':[]}; 313 hits[lid]['fids'].push(fid); 314 } 315 } 316 geoInkMap.mapOnMousePick(hits); 317 } 318 this.pixelToLocation=function(x,y,pixelReference){ // CONTROL/PAGE/VIEWPORT 319 var a=map.pixelsToPositions([[x,y]]); 320 return a[0]; 321 } 322 this.locationToPixel=function(x,y){ 323 var a=map.positionsToPixels([[x,y]]); 324 return a[0]; 325 } 326 this.getMapContainer=function(){ 327 return map.getMapContainer(); 328 } 329} 330// ================================================================================================================================================================== 331 332
333var geoBingMapInfobox,tooltipTemplate='<div id="tooltipTemplate" style="background-color:white;height:14px;width:150px;padding:1px;text-align:center">{title}</div>'; 334function geoClassBingMap(options){ 335 var b,isIE8=0; 336 var startExtents,maxExtents,mousepos; 337 var mapType=Microsoft.Maps.MapTypeId.aerial; 338 if(geoChiConfig.map.bingStartMap=='BRITISH_OS')mapType=Microsoft.Maps.MapTypeId.ordnanceSurvey; 339 if(geoChiConfig.map.bingStartMap=='ROAD')mapType=Microsoft.Maps.MapTypeId.road; 340 var opts={ 341 credentials:"Ar3D9RfOxsz6SYaBBrIZrQUzpJZkK-uyviPDJppleg2OanZhuKdSLwIN6ADqfZXG", 342 showScalebar:false, 343 mapTypeId:mapType, 344 //showDashboard:false, 345 showMapTypeSelector:false, 346 showZoomButtons:true, 347 navigationBarMode:geoChiConfig.map.showDrawTools=='BING'?Microsoft.Maps.NavigationBarMode.default:Microsoft.Maps.NavigationBarMode.compact,// compact,default,minified 348 showLocateMeButton:true 349 } 350 if(options.bounds){ 351 b=options.bounds; 352 this.startExtents=Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(b[1],b[0]),new Microsoft.Maps.Location(b[3],b[2])); 353 opts['bounds']=this.startExtents; 354 } 355 if(options.maxBounds){ 356 b=options.maxBounds; 357 this.maxExtents=Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(b[1],b[0]),new Microsoft.Maps.Location(b[3],b[2])); 358 opts['maxBounds']=this.maxExtents; 359 } 360 if(options.showScalebar)opts['showScalebar']=true; 361 geoBingMap=new Microsoft.Maps.Map(document.getElementById("mapsPanel"),opts); 362 if(geoChiConfig.map.showDrawTools=='BING'){ 363 Microsoft.Maps.loadModule('Microsoft.Maps.DrawingTools',function(){ 364 var tools = new Microsoft.Maps.DrawingTools(geoBingMap); 365 tools.showDrawingManager(function(a){ 366 drawingManager=a;//public reference to the drawing manager 367 Microsoft.Maps.Events.addHandler(a,'drawingEnded',geoDrawingEnded); 368 }) 369 }); 370 } 371 Microsoft.Maps.loadModule("Microsoft.Maps.SpatialMath"); 372 Microsoft.Maps.Events.addHandler(geoBingMap,'mousedown',geoBingMapMouseUp); 373 Microsoft.Maps.Events.addHandler(geoBingMap,'mousemove',geoBingMapMouseMove); 374 Microsoft.Maps.Events.addHandler(geoBingMap,'viewchangeend',geoBingViewChangeEnd); 375 Microsoft.Maps.Events.addHandler(geoBingMap,'viewchange',geoBingViewChange); 376 377/* 378keep me 379 //Create an infobox to use as a tooltip when hovering. 380 geoBingMapTooltip = new Microsoft.Maps.Infobox(geoBingMap.getCenter(), { 381 visible: false, 382 showPointer: false, 383 showCloseButton: false, 384 offset: new Microsoft.Maps.Point(-75, 10) 385 }); 386 387 geoBingMapTooltip.setMap(geoBingMap); 388*/ 389 //Create an infobox for displaying detailed information. 390 geoBingMapInfobox = new Microsoft.Maps.Infobox(geoBingMap.getCenter(), { 391 visible: false 392 }); 393 geoBingMapInfobox.setMap(geoBingMap); 394 395 this.disableNavigation=function(){geoBingMap.setOptions({disablePanning:true,disableScrollWheelZoom:true,disableZooming:true,showDashboard:false,showLocateMeButton:false});} 396 this.enableNavigation=function(){geoBingMap.setOptions({disablePanning:false,disableScrollWheelZoom:false,disableZooming:false,showDashboard:true,showLocateMeButton:true});} 397 this.getTest=function(){return '99';} 398 this.getZoom=function(){return geoBingMap.getZoom();} 399 this.getCenter=function(){var c=geoBingMap.getCenter();return [c.longitude,c.latitude];} 400 this.getExtents=function(){var v=geoBingMap.getBounds();return [v.getWest(),v.getSouth(),v.getEast(),v.getNorth()];} 401 this.setZoom=function(z){if(z>maxMapZoom)z=maxMapZoom;if(z<minMapZoom)z=minMapZoom;geoBingMap.setView({zoom:z});} 402 this.setCenter=function(x,y){var p=new Microsoft.Maps.Location(y,x);geoBingMap.setView({center:p});} 403 this.setCenterZoom=function(x,y,z){var p=new Microsoft.Maps.Location(y,x);if(z>maxMapZoom)z=maxMapZoom;if(z<minMapZoom)z=minMapZoom;geoBingMap.setView({center:p,zoom:z});} 404 this.setExtents=function(x1,y1,x2,y2){var v=Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(y1,x1),new Microsoft.Maps.Location(y2,x2));
404geoBingMap.setView({bounds:v});} 405 this.setMapType=function(type){ 406 //Microsoft.Maps.MapTypeId.[Name] where [Name] can be any of the following values. 407 //ordnanceSurvey, road, aerial 408 var t=Microsoft.Maps.MapTypeId.ordnanceSurvey; 409 geoBingMap.setView({mapTypeId:t}); 410 } 411 this.mapViewChangeEnd=function(){ 412 this.zoom=this.getZoom();this.center=this.getCenter();this.extents=this.getExtents(); 413 if(geoOnMapChangeViewEnd)geoOnMapChangeViewEnd(this.zoom,this.center,this.extents); 414 } 415 this.addLayer=function(lid){ 416 var l=new Microsoft.Maps.Layer(); 417 geoBingMap.layers.insert(l); 418 geoLayerSet[lid]=l; 419 } 420 this.addLayerWMTS=function(lid,url){ 421 var ts=new Microsoft.Maps.TileSource({uriConstructor:url,minZoom:0,maxZoom:24}); 422 var l=new Microsoft.Maps.TileLayer({mercator:ts}); 423 geoBingMap.layers.insert(l); 424 geoLayerSet[lid]=l; 425 } 426 this.addLayerTiled=function(lid,url,opacity,minZoom,maxZoom){ 427 var ts,o=opacity; 428 if(o==undefined)o=1; 429 if(minZoom==undefined)minZoom=0; 430 if(maxZoom==undefined)maxZoom=24; 431 if(url.indexOf('{zoomA}')>-1){ 432 ts=new Microsoft.Maps.TileSource({ 433 minZoom:minZoom,maxZoom:maxZoom, 434 uriConstructor:function(coord){ // coord is a PyramidTileId with : z,y,zoom,pixwidth,pixheight. 435 var ymax=1<<coord.zoom; 436 var y=ymax-coord.y-1; 437 var u=url; 438 if(u.indexOf('png-jpg')>-1){ 439 if(coord.zoom>18){ 440 u=u.replace('png-jpg','jpg'); 441 u=u.replace('/{zoomA}','/jpg/{zoomA}'); 442 }else{ 443 u=u.replace('png-jpg','png'); 444 } 445 } 446 u=u.replace('{x}',coord.x).replace('{y}',y).replace('{zoomA}',coord.zoom); 447 return u; 448 } 449 }); 450 }else{ 451 ts=new Microsoft.Maps.TileSource({ 452 minZoom:minZoom, 453 maxZoom:maxZoom, 454 uriConstructor:url //'{zoom}/{x}/{y}.png' 455 }); 456 } 457 var l=new Microsoft.Maps.TileLayer({mercator:ts,opacity:o}); 458 geoBingMap.layers.insert(l); 459 geoLayerSet[lid]=l; 460 } 461 this.setLayerOpacity=function(lid,d){geoLayerSet[lid].setOptions({opacity:d});} 462 this.addLayerWMS=function(lid,url){ 463 var NOAAWeatherRadar = new Microsoft.Maps.TileLayer({ 464 mercator: new Microsoft.Maps.TileSource({ 465 uriConstructor: 'http://idpgis.ncep.noaa.gov/arcgis/services/NWS_Observations/radar_base_reflectivity/MapServer/WmsServer?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&LAYERS=1&STYLES=default&FORMAT=image/png&TRANSPARENT=TRUE&CRS=CRS:84&BBOX={bbox}&WIDTH=256&HEIGHT=256', 466 minZoom: 3, 467 maxZoom: 10, 468 bounds: Microsoft.Maps.LocationRect.fromEdges(50.415613, -127.629361, 21.661516, -66.526907) 469 }) 470 }); 471 map.layers.insert(NOAAWeatherRadar); 472 var tl,ts=new Microsoft.Maps.TileSource({uriConstructor:url,minZoom:1,maxZoom:15}); 473 tl=new Microsoft.Maps.TileLayer({mercator:ts}); 474 geoBingMap.layers.insert(tl); 475 } 476 477 this.zapLayer=function(lid){geoBingMap.entities.remove(mlayers[lid]);delete geoLayerSet[lid];} 478 this.showLayer=function(lid){geoLayerSet[lid].setVisible(true);} 479 this.hideLayer=function(lid){geoLayerSet[lid].setVisible(false);} 480 this.clearLayer=function(lid){ 481 if(geoLayerSet[lid]){ 482 if(geoLayerSet[lid].clear)geoLayerSet[lid].clear(); 483 else if(geoLayerSet[lid].setVisible)geoLayerSet[lid].setVisible(false); 484 } 485 } 486 this.layerSetOpacity=function(lid,d){geoLayerSet[lid].setOptions({opacity:d});} 487 this.clearMap=function(){geoBingMap.entities.clear();geoBingMap.layers.clear();} 488 this.addWMTS=function(url){ 489 var url='http://d3rykcmoi4kytu.cloudfront.net/lidar/latest/2m_dtm/{zoom}/{x}/{y}.png'; // to work {zoom}/{x}/{y} used instead of {z}/{x}/{y} which is shown on wales portal site : http://lle.gov.wales/catalogue/item/LidarCompositeDataset/?lang=en 490 var tl,ts=new Microsoft.Maps.TileSource({uriConstructor:url,minZoom:0,maxZoom:15}); 491 tl=new Microsoft.Maps.TileLayer({mercator:ts}); 492 geoBingMap.layers.insert(tl); 493 } 494 this.plotPoint=function(p,lid,fid,opts,label,icon,visible,balloon){
495 var a,c,o,s='sym/pinRed16x16.png',size=16; 496 if(icon)s=icon;else if(opts.icon)s=opts.icon; 497 if(opts.iconSize)size=opts.iconSize; 498 //o={icon:s,anchor:new Microsoft.Maps.Point(size/2,size/2)}; 499 o={icon:s}; 500 if(label){ 501 o['title']=trim(label); 502 o['anchor']=new Microsoft.Maps.Point(size/2,size/2); 503 } 504 c=new Microsoft.Maps.Location(p[1],p[0]); 505 a=new Microsoft.Maps.Pushpin(c,o); 506 if(balloon){ 507 //Store some metadata with the pushpin. 508 a.metadata = { 509 //title: '<b>Pu</b>shpin ' + 99, 510 description: balloon 511 }; 512 Microsoft.Maps.Events.addHandler(a, 'click', pushpinClicked); 513 } 514/* 515 keep me for adding tooltips 516 Microsoft.Maps.Events.addHandler(a, 'mouseover', pushpinHovered); 517 Microsoft.Maps.Events.addHandler(a, 'mouseout', closeTooltip); 518*/ 519 a.inkLayerID=lid;a.inkFid=fid; 520 Microsoft.Maps.Events.addHandler(a,'click',geoBingMapPinClick); 521 geoLayerSet[lid].add(a); 522 } 523 this.plotPline=function(p,lid,fid,opts,visible,label){ 524 var a,i,j,q,r,o={strokeColor:geoBingHexToRgb(opts.plineColor,opts.plineOpacity),strokeThickness:opts.plineWidth}; 525 for(j=0;j<p.length;j++){ 526 q=p[j];r=[]; 527 for(i=0;i<q.length;i++){r.push(new Microsoft.Maps.Location(q[i][1],q[i][0]));} 528 a=new Microsoft.Maps.Polyline(r); 529 a.inkLayerID=lid;a.inkFid=fid; 530 a.setOptions(o); 531 Microsoft.Maps.Events.addHandler(a,'click',geoBingMapPinClick); 532 geoLayerSet[lid].add(a); 533 } 534 } 535 this.plotPolygon=function(p,lid,fid,opts,visible,label){ 536 // p is array of arrays, first array is exterior, remaining are holes and must be reverse order 537 var a,i,j,r=[],q=[],o,c,ic,x=0,y=0,n=0; 538 o={fillColor:geoBingHexToRgb(opts.fillColor,opts.fillOpacity),strokeThickness:opts.strokeWidth,strokeColor:geoBingHexToRgb(opts.strokeColor,opts.strokeOpacity)}; 539 for(i=0;i<p.length;i++){ 540 m=p[i];r=[]; 541 ic=geoJasonRingIsClockWise(m); 542 if((i==0&&!ic)||(i>0&&ic))for(j=m.length-1;j>=0;j--){ 543 n++;x+=m[j][1];y+=m[j][0]; // collecting average for label centroid 544 r.push(new Microsoft.Maps.Location(m[j][1],m[j][0])); 545 } 546 else for(j=0;j<m.length;j++){ 547 n++;x+=m[j][1];y+=m[j][0]; // collecting average for label centroid 548 r.push(new Microsoft.Maps.Location(m[j][1],m[j][0])); 549 } 550 q.push(r); 551 } 552 a=new Microsoft.Maps.Polygon(q); 553 a.setOptions(o); 554 a.inkLayerID=lid;a.inkFid=fid; 555 //if(lid!='SELECT_LAYER') 556 Microsoft.Maps.Events.addHandler(a,'click',geoBingMapPinClick); 557 geoLayerSet[lid].add(a); 558 if(label){ 559 o={icon:'sym/pinNull2x2.png',title:trim(label),anchor:new Microsoft.Maps.Point(2,2)}; 560 c=new Microsoft.Maps.Location(x/n,y/n); 561 a=new Microsoft.Maps.Pushpin(c,o); 562 geoLayerSet[lid].add(a); 563 } 564 } 565 this.pick=function(x,y){ 566 var f=0,d,tl,a,b,i,l,r,lid,fid,hits={}, 567 e=this.getExtents(); 568 p=new Microsoft.Maps.Location(y,x); 569 a=new Microsoft.Maps.Location(e[1],e[0]); 570 b=new Microsoft.Maps.Location(e[3],e[2]); 571 572 //tl=isTouchDevice?.02:.008; 573 tl=.02; 574 575 if(geoInkMap.activeTool=='SELECT')tl=.002; 576 577 r=Microsoft.Maps.SpatialMath.Geometry.distance(a,b)*tl; // diagonal size of map box 578 for(i=0;i<geoBingMap.layers.length;i++){ 579 if(geoBingMap.layers[i].getPrimitives){ 580 l=geoBingMap.layers[i].getPrimitives(); 581 for(j=0;j<l.length;j++){ 582 d=Microsoft.Maps.SpatialMath.Geometry.distance(l[j],p); 583 if(d<=r){// , Microsoft.Maps.SpatialMath.DistanceUnits.Meters 584 lid=l[j].inkLayerID; 585 if(lid!=='SELECT_LAYER'){ 586 if(!hits[lid])hits[lid]={'fids':[]}; 587 fid=l[j].inkFid; 588 if(Array.isArray(fid)){ 589 for(j=0;j<fid.length;j++){ 590 hits[lid]['fids'].push(fid[j]); 591 } 592 }else{hits[lid]['fids'].push(fid);} 593 f=1; 594 } 595 } 596 } 597 } 598 } 599 if(f)geoInkMap.mapOnMousePick(hits); 600 } 601 this.pixelTest=function(){ 602 var loc = geoBingMap.getCenter(); 603 var point = geoBingMap.tryLocationToPixel(loc, Microsoft.Maps.PixelReference.control); 604 var point = new Microsoft.Maps.Point(100, 100); 605 var loc = geoBingMap.tryPixelToLocation(point, Microsoft.Maps.PixelReference.control); 606 } 607 this.pixelToLocation=function(x,y,pixelReference){ // CONTROL/PAGE/VIEWPORT 608 var pr; 609 if(pixelReference=='PAGE')pr=Microsoft.Maps.PixelReference.page; 610 else if(pixelReference=='VIEWPORT')pr=Microsoft.Maps.PixelReference.viewport; 611 else pr=Microsoft.Maps.PixelReference.control; // default 612 var c=geoBingMap.tryPixelToLocation(new Microsoft.Maps.Point(x,y),pr); 613 return [c.longitude,c.latitude]; 614 } 615 this.locationToPixel=function(x,y){ 616 var c=geoBingMap.tryLocationToPixel(new Microsoft.Maps.Location(y,x),Microsoft.Maps.PixelReference.control); 617 return [c.x,c.y]; 618 } 619} 620/* 621keep me 622 function pushpinHovered(e) { 623 //Hide the infobox
624 geoBingMapInfobox.setOptions({ visible: false }); 625 //geoBingMapTooltip.setOptions({ visible: false }); 626 627 //Make sure the infobox has metadata to display. 628 if (e.target.metadata) { 629 //Set the infobox options with the metadata of the pushpin. 630 geoBingMapTooltip.setOptions({ 631 location: e.target.getLocation(), 632 htmlContent: tooltipTemplate.replace('{title}', e.target.metadata.title), 633 visible: true 634 }); 635 } 636 } 637 638 function closeTooltip() { 639 //Close the tooltip. 640 geoBingMapTooltip.setOptions({ 641 visible: false 642 }); 643 } 644 645*/ 646 function pushpinClicked(e) { 647 //Hide the tooltip 648 //closeTooltip(); 649 650 //Make sure the infobox has metadata to display. 651 if (e.target.metadata) { 652 //Set the infobox options with the metadata of the pushpin. 653 geoBingMapInfobox.setOptions({ 654 location: e.target.getLocation(), 655 // title: e.target.metadata.title, 656 description: e.target.metadata.description, 657 visible: true 658 }); 659 } 660 } 661 662 663function geoDrawingEnded(){ 664 var x,y,shapes=drawingManager.getPrimitives(); 665 x=shapes[0].geometry.x; 666 y=shapes[0].geometry.y; 667 var m=geoRecSet.getCurrentRec(); 668 m['chi_geometry'].push([0,coordWGS84toOS([x,y]),m.chi_fid+'-'+getGetFuid()]); 669 geoInkMap.drawEditLayer(); 670 setTimeout('omniToolGrab();',300); 671 //geoRecSet.prettyPrintCurrent(); 672} 673function geoBingHexToRgb(hex,opac){var c=hex2RGB(hex);return new Microsoft.Maps.Color(opac,c[0],c[1],c[2])}; 674function geoBingMapMouseUp(e){geoInkMap.mapOnMouseUp([e.location.longitude,e.location.latitude]);} 675function geoBingMapMouseMove(e){ 676 geoMapFrame.mousepos=[e.location.longitude,e.location.latitude]; 677 geoInkMap.mapOnMouseMove([e.location.longitude,e.location.latitude]); 678} 679function geoBingMapPinClick(e){ 680 /* 681 if(geoInkMap.activeTool!='SELECT_LAYER'){ 682 if(geoInkMap.activeTool=='SELECT' && e.target.inkLayerID=='EDIT_LAYER'){ 683 geoInkMap.mapOnMousePick({EDIT_LAYER:{fids:[e.target.inkFid]}}); // if clicked on edit layer object return only that id 684 } 685 else{ 686 geoMapFrame.pick(e.location.longitude,e.location.latitude); // other wise get all ids bellow click point 687 } 688 } 689 */ 690 geoMapFrame.pick(e.location.longitude,e.location.latitude); // other wise get all ids bellow click point 691 692} 693// be sure pinching realy has ended 694var feedResizeInterval,feedLastResizeTime=performance.now(); 695function geoBingViewChangeEnd(){ 696 geoInkMap.mapOnViewChangeEnd(); 697// var a=new Date(); 698// if((a-feedLastResizeTime)>1000){ 699// feedResizeInterval=new Date(); 700// setTimeout('geoBingViewChangeEndD()',600); 701// } 702} 703function geoBingViewChangeEndD(){ 704 var a=new Date(); 705 if(feedInterval=a-feedResizeInterval>500 && a-feedLastResizeTime>1000){ 706 geoInkMap.mapOnViewChangeEnd(); 707 feedFastResizeTime=new Date(); 708 }else{ 709 geoInkMap.mapOnViewChange(); 710 } 711} 712function geoBingViewChange(){ 713 geoInkMap.mapOnViewChange(); 714} 715//-------------------------------------- overlay --------------------------------------------------------------------------------------------- 716var geoLastOverlay=null; 717function geoMakeTopoOverlay1(){ 718 vvvv.prototype=new Microsoft.Maps.CustomOverlay(); 719 function vvvv(bounds,image) { 720 this.bounds=bounds; 721 this.image=image; 722 } 723 //Implement the onAdd method to set up DOM elements, and use setHtmlElement to bind it with the overlay. 724 vvvv.prototype.onAdd = function () { 725 //Create an image element that will be used as the overlay. 726 img=document.createElement('img'); 727 img.src=this.image; 728 img.style.width='100%'; 729 img.style.height='100%'; 730 img.style.position='absolute'; 731 this.setHtmlElement(img); 732 }; 733 //Implement the onLoad method to perform custom operations of rendering the DOM element. 734 vvvv.prototype.onLoad=function(){ 735 repositionOverlay(); 736 //Update the position of the image when the view changes. 737 Microsoft.Maps.Events.addHandler(geoBingMap, 'viewchange', function () { 738 repositionOverlay(); 739 }); 740 }; 741 function repositionOverlay() { 742 //Streach and position the image based on the bounding box pixel coordinates. 743 var topLeft=geoBingMap.tryLocationToPixel(bounds.getNorthwest(), Microsoft.Maps.PixelReference.control), 744 bottomRight=geoBingMap.tryLocationToPixel(bounds.getSoutheast(), Microsoft.Maps.PixelReference.control); 745 746 img.style.left = topLeft.x + 'px'; 747 img.style.top = topLeft.y + 'px'; 748 img.style.width = (bottomRight.x - topLeft.x) + 'px'; 749 img.style.height = (bottomRight.y - topLeft.y) + 'px'; 750 751 //img.style.left = 40 + 'px'; 752 //img.style.top = 40 + 'px'; 753 //img.style.width = 500 + 'px'; 754 //img.style.height = 500 + 'px'; 755 756 } 757 //The bounding box and url for the image to overlay. 758 var bounds=Microsoft.Maps.LocationRect.fromCorners(new Microsoft.Maps.Location(52.19, -4.18), new Microsoft.Maps.Location(51.82, -3.43)); 759 var imageSrc='ic/info.png';
760 var overlay = new vvvv(bounds, imageSrc); 761 if(geoLastOverlay)geoBingMap.layers.remove(geoLastOverlay); 762 geoBingMap.layers.insert(overlay); 763 geoLastOverlay=overlay; 764 765 zp('-------------ok'); 766 767}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.