mxn.geocommons.core.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. mxn.register('geocommons', {
  2. Mapstraction: {
  3. init: function(element, api) {
  4. var me = this;
  5. this.element = element;
  6. Maker.maker_host='http://maker.geocommons.com';
  7. Maker.finder_host='http://finder.geocommons.com';
  8. Maker.core_host='http://geocommons.com';
  9. },
  10. applyOptions: function(){
  11. var map = this.maps[this.api];
  12. // TODO: Add provider code
  13. },
  14. resizeTo: function(width, height){
  15. var map = this.maps[this.api];
  16. map.setSize(width,height);
  17. },
  18. addControls: function( args ) {
  19. var map = this.maps[this.api];
  20. map.showControl("Zoom", args.zoom || false);
  21. map.showControl("Layers", args.layers || false);
  22. map.showControl("Styles", args.styles || false);
  23. map.showControl("Basemap", args.map_type || false);
  24. map.showControl("Legend", args.legend || false, "open");
  25. // showControl("Legend", true, "close");
  26. },
  27. addSmallControls: function() {
  28. var map = this.maps[this.api];
  29. showControl("Zoom", args.zoom);
  30. showControl("Legend", args.legend, "open");
  31. },
  32. addLargeControls: function() {
  33. var map = this.maps[this.api];
  34. showControl("Zoom", args.zoom);
  35. showControl("Layers", args.layers);
  36. showControl("Legend", args.legend, "open");
  37. },
  38. addMapTypeControls: function() {
  39. var map = this.maps[this.api];
  40. // TODO: Add provider code
  41. },
  42. dragging: function(on) {
  43. var map = this.maps[this.api];
  44. // TODO: Add provider code
  45. },
  46. setCenterAndZoom: function(point, zoom) {
  47. var map = this.maps[this.api];
  48. map.setCenterZoom(point.lat, point.lon,zoom);
  49. },
  50. getCenter: function() {
  51. var map = this.maps[this.api];
  52. var point = map.getCenterZoom()[0];
  53. return mxn.LatLonPoint(point.lat,point.lon);
  54. },
  55. setCenter: function(point, options) {
  56. var map = this.maps[this.api];
  57. map.setCenter(point.lat, point.lon);
  58. },
  59. setZoom: function(zoom) {
  60. var map = this.maps[this.api];
  61. map.setZoom(zoom);
  62. },
  63. getZoom: function() {
  64. var map = this.maps[this.api];
  65. return map.getZoom();
  66. },
  67. getZoomLevelForBoundingBox: function( bbox ) {
  68. var map = this.maps[this.api];
  69. // NE and SW points from the bounding box.
  70. var ne = bbox.getNorthEast();
  71. var sw = bbox.getSouthWest();
  72. var zoom;
  73. // TODO: Add provider code
  74. return zoom;
  75. },
  76. setMapType: function(type) {
  77. var map = this.maps[this.api];
  78. switch(type) {
  79. case mxn.Mapstraction.ROAD:
  80. map.setMapProvider("OpenStreetMap (road)");
  81. break;
  82. case mxn.Mapstraction.SATELLITE:
  83. map.setMapProvider("BlueMarble");
  84. break;
  85. default:
  86. map.setMapProvider(type);
  87. }
  88. },
  89. getMapType: function() {
  90. var map = this.maps[this.api];
  91. switch(map.getMapProvider) {
  92. case "OpenStreetMap (Road)":
  93. retu
  94. }
  95. // TODO: Add provider code
  96. //return mxn.Mapstraction.ROAD;
  97. //return mxn.Mapstraction.SATELLITE;
  98. //return mxn.Mapstraction.HYBRID;
  99. },
  100. getBounds: function () {
  101. var map = this.maps[this.api];
  102. var extent = map.getExtent();
  103. return new mxn.BoundingBox( extent.northWest.lat, extent.southEast.lon, extent.southEast.lat, extent.northWest.lon);
  104. },
  105. setBounds: function(bounds){
  106. var map = this.maps[this.api];
  107. var sw = bounds.getSouthWest();
  108. var ne = bounds.getNorthEast();
  109. map.setExtent(ne.lat,sw.lat,ne.lon,sw.lon);
  110. },
  111. addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
  112. var map = this.maps[this.api];
  113. // TODO: Add provider code
  114. },
  115. addOverlay: function(url, autoCenterAndZoom) {
  116. var map = this.maps[this.api];
  117. var me = this;
  118. Maker.load_map(this.element.id, url);
  119. setTimeout(function() { me.maps[me.api] = swfobject.getObjectById(FlashMap.dom_id);}, 500);
  120. },
  121. addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
  122. var map = this.maps[this.api];
  123. // TODO: Add provider code
  124. },
  125. toggleTileLayer: function(tile_url) {
  126. var map = this.maps[this.api];
  127. // TODO: Add provider code
  128. },
  129. getPixelRatio: function() {
  130. var map = this.maps[this.api];
  131. // TODO: Add provider code
  132. },
  133. mousePosition: function(element) {
  134. var map = this.maps[this.api];
  135. // TODO: Add provider code
  136. }
  137. },
  138. LatLonPoint: {
  139. toProprietary: function() {
  140. // TODO: Add provider code
  141. },
  142. fromProprietary: function(point) {
  143. // TODO: Add provider code
  144. }
  145. },
  146. Marker: {
  147. toProprietary: function() {
  148. // TODO: Add provider code
  149. },
  150. openBubble: function() {
  151. // TODO: Add provider code
  152. },
  153. hide: function() {
  154. // TODO: Add provider code
  155. },
  156. show: function() {
  157. // TODO: Add provider code
  158. },
  159. update: function() {
  160. // TODO: Add provider code
  161. }
  162. },
  163. Polyline: {
  164. toProprietary: function() {
  165. // TODO: Add provider code
  166. },
  167. show: function() {
  168. // TODO: Add provider code
  169. },
  170. hide: function() {
  171. // TODO: Add provider code
  172. }
  173. }
  174. });