Interactive interface for browsing global, full-resolution satellite imagery
First cut at filling out functions of map class; accepts a div and config on instantiation. Not all config parameters are handled, but it's a start.
Ryan Boller2ffefdfa9c3b
diff --git a/js/map.js b/js/map.jsindex cd7009ae5..794e65272 100644--- a/js/map.js+++ b/js/map.js@@ -1,4 +1,6 @@-SOTE.widget.Map.prototype = new SOTE.widget.Component;+/** SOTE.widget.Map.prototype = new SOTE.widget.Component; */+SOTE.namespace("SOTE.widget.Map");+/*** Instantiate the map@@ -16,7 +18,72 @@ SOTE.widget.Map.prototype = new SOTE.widget.Component;**/SOTE.widget.Map = function(containerId, config){- // Content++ // Get the ID of the container element+ this.container=document.getElementById(containerId);+ if (this.container==null){+ this.setStatus("Error: element '"+containerId+"' not found!",true);+ return;+ }++ // Store the container's ID+ this.containerId=containerId;+ this.id = containerId;++ // Define an object for holding configuration+ if (config===undefined){+ config={};+ }++ if(config.hasControls === undefined){+ config.hasControls = true;+ }++ if(config.isSelectable === undefined){+ config.isSelectable = false;+ }++ if(config.bbox === undefined){+ config.bbox = "-180, -90, 180, 90";+ }++ // TODO: are these necessary?+ if(config.register === undefined){+ config.register = true;+ }++ if(config.dataSourceUrl === undefined){+ config.dataSourceUrl = null;+ }++ if(config.maxWidth === undefined){+ config.maxWidth = null;+ }++ if(config.maxHeight === undefined){+ config.maxHeight = null;+ }+++ // this.selectionEvent = new YAHOO.util.CustomEvent("SelectionEvent",this);++ this.hasControls = config.hasControls;+ this.isSelectable = config.isSelectable;+ this.bbox = config.bbox;++ this.value = "";+ this.register = config.register;+ this.maxWidth = config.maxWidth;+ this.maxHeight = config.maxHeight;+ this.dataSourceUrl = config.dataSourceUrl;+ this.statusStr = "";+ this.disabled = false;+ // this.render();+++ // Initialize the map+ this.init();+};/**@@ -29,7 +96,129 @@ SOTE.widget.Map = function(containerId, config){**/SOTE.widget.Map.prototype.init = function(){- // Content++ // Get rid of address bar on iphone/ipod+ var fixSize = function() {+ window.scrollTo(0,0);+ document.body.style.height = '100%';+ if (!(/(iphone|ipod)/.test(navigator.userAgent.toLowerCase()))) {+ if (document.body.parentNode) {+ document.body.parentNode.style.height = '100%';+ }+ }+ };+ setTimeout(fixSize, 700);+ setTimeout(fixSize, 1500);++ // Init map, include support for mobile devices+ this.map = new OpenLayers.Map({+ div: this.containerId,+ theme: null,+ controls: [+ new OpenLayers.Control.Attribution(),+ new OpenLayers.Control.LayerSwitcher({'ascending':false}),+ new OpenLayers.Control.Permalink(),+ new OpenLayers.Control.ScaleLine(),+ new OpenLayers.Control.Permalink('permalink'),+ //new OpenLayers.Control.MousePosition(),+ new OpenLayers.Control.OverviewMap()++ ],+ layers: [+ new OpenLayers.Layer.OSM("OpenStreetMap", null, {+ transitionEffect: 'resize',+ sphericalMercator: true+ }),+ // new OpenLayers.Layer.WMS("NASA WMS Service",+ // "http://onearth.jpl.nasa.gov/wms.cgi?",+ // {+ // layers: 'global_mosaic'+ // , styles: 'visual'+ // },+ // {+ // tileSize: new OpenLayers.Size(512,512)+ // }+ // ),+ new OpenLayers.Layer.VirtualEarth("Shaded", {+ type: VEMapStyle.Shaded,+ transitionEffect: 'resize',+ sphericalMercator: true+ })//,+ // new OpenLayers.Layer.VirtualEarth("Hybrid", {+ // type: VEMapStyle.Hybrid,+ // transitionEffect: 'resize'+ // }),+ // new OpenLayers.Layer.VirtualEarth("Aerial", {+ // type: VEMapStyle.Aerial,+ // transitionEffect: 'resize'+ // })++ ],+ //center: new OpenLayers.LonLat(742000, 5861000),+ zoom: 3+ });++++ if (this.hasControls)+ {+ this.map.addControl(new OpenLayers.Control.TouchNavigation({+ dragPanOptions: {+ enableKinetic: true+ }+ }));++ this.map.addControl(new OpenLayers.Control.ZoomPanel());+ this.map.addControl(new OpenLayers.Control.KeyboardDefaults());+ this.map.addControl(new OpenLayers.Control.Navigation());++ // this.map.addControl(new OpenLayers.Control.PanZoomBar());+ }++ // Enables a zoom box by shift-clicking;+ // TODO: note that it is apparently already enabled when the "Navigation" control is added+ if (this.isSelectable)+ {+ this.map.addControl(new OpenLayers.Control.ZoomBox());+ }+++ this.map.setCenter(+ new OpenLayers.LonLat(-71.147, 42.472).transform(+ new OpenLayers.Projection("EPSG:4326"),+ this.map.getProjectionObject()+ ), 12);+++ // TODO: Parse bounding box string and apply to map+ // bbox is getting passed alright, extents are not being set properly;+ // something is wrong with projection - annotated box draws fine on Bing maps, not on OSM+ // wait for real map data and configure proper extents, etc++ var extent = new OpenLayers.Bounds.fromString(this.bbox, false).transform(+ new OpenLayers.Projection("EPSG:4326"),+ this.map.getProjectionObject());+ this.map.zoomToExtent(extent, true);+++ // !!! speaking a different language. This shows up as a small box off the coast of africa+ // will probably have to reproject coordinates as done above for setting map center.+ //(-45,-45, 0, 45).transform(+ var bounds = new OpenLayers.Bounds(-180, -85, 180, 85).transform(+ new OpenLayers.Projection("EPSG:4326"),+ this.map.getProjectionObject());+ //this.map.zoomToExtent(bounds);+ var boxes = new OpenLayers.Layer.Boxes("boxes");+ var box = new OpenLayers.Marker.Box(bounds);+ boxes.addMarker(box);+ this.map.addLayer(boxes);++ //this.map.zoomToExtent(bounds, true);+++++};/**