mxn.geocommons.core.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. case mxn.Mapstraction.HYBRID:
  86. map.setMapProvider("Google Hybrid");
  87. break;
  88. default:
  89. map.setMapProvider(type);
  90. }
  91. },
  92. getMapType: function() {
  93. var map = this.maps[this.api];
  94. switch(map.getMapProvider) {
  95. case "OpenStreetMap (Road)":
  96. retu
  97. }
  98. // TODO: Add provider code
  99. //return mxn.Mapstraction.ROAD;
  100. //return mxn.Mapstraction.SATELLITE;
  101. //return mxn.Mapstraction.HYBRID;
  102. },
  103. getBounds: function () {
  104. var map = this.maps[this.api];
  105. var extent = map.getExtent();
  106. return new mxn.BoundingBox( extent.northWest.lat, extent.southEast.lon, extent.southEast.lat, extent.northWest.lon);
  107. },
  108. setBounds: function(bounds){
  109. var map = this.maps[this.api];
  110. var sw = bounds.getSouthWest();
  111. var ne = bounds.getNorthEast();
  112. map.setExtent(ne.lat,sw.lat,ne.lon,sw.lon);
  113. },
  114. addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
  115. var map = this.maps[this.api];
  116. // TODO: Add provider code
  117. },
  118. addOverlay: function(url, autoCenterAndZoom) {
  119. var map = this.maps[this.api];
  120. var me = this;
  121. Maker.load_map(this.element.id, url);
  122. setTimeout(function() { me.maps[me.api] = swfobject.getObjectById(FlashMap.dom_id);}, 500);
  123. },
  124. addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
  125. var map = this.maps[this.api];
  126. // TODO: Add provider code
  127. },
  128. toggleTileLayer: function(tile_url) {
  129. var map = this.maps[this.api];
  130. // TODO: Add provider code
  131. },
  132. getPixelRatio: function() {
  133. var map = this.maps[this.api];
  134. // TODO: Add provider code
  135. },
  136. mousePosition: function(element) {
  137. var map = this.maps[this.api];
  138. // TODO: Add provider code
  139. }
  140. },
  141. LatLonPoint: {
  142. toProprietary: function() {
  143. // TODO: Add provider code
  144. },
  145. fromProprietary: function(googlePoint) {
  146. // TODO: Add provider code
  147. }
  148. },
  149. Marker: {
  150. toProprietary: function() {
  151. // TODO: Add provider code
  152. },
  153. openBubble: function() {
  154. // TODO: Add provider code
  155. },
  156. hide: function() {
  157. // TODO: Add provider code
  158. },
  159. show: function() {
  160. // TODO: Add provider code
  161. },
  162. update: function() {
  163. // TODO: Add provider code
  164. }
  165. },
  166. Polyline: {
  167. toProprietary: function() {
  168. // TODO: Add provider code
  169. },
  170. show: function() {
  171. // TODO: Add provider code
  172. },
  173. hide: function() {
  174. // TODO: Add provider code
  175. }
  176. }
  177. });