mapstraction-rails 2.0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/Gemfile +4 -0
  2. data/Gemfile.lock +14 -0
  3. data/LICENSE +22 -0
  4. data/README.md +32 -0
  5. data/Rakefile +2 -0
  6. data/lib/mapstraction/engine.rb +4 -0
  7. data/lib/mapstraction/version.rb +3 -0
  8. data/lib/mapstraction.rb +5 -0
  9. data/mapstraction/.gitignore +17 -0
  10. data/mapstraction.gemspec +17 -0
  11. data/vendor/.DS_Store +0 -0
  12. data/vendor/assets/.DS_Store +0 -0
  13. data/vendor/assets/javascripts/mxn-min.js +15 -0
  14. data/vendor/assets/javascripts/mxn.cartociudad.geocoder-min.js +15 -0
  15. data/vendor/assets/javascripts/mxn.cartociudad.geocoder.js +46 -0
  16. data/vendor/assets/javascripts/mxn.cloudmade.core-min.js +15 -0
  17. data/vendor/assets/javascripts/mxn.cloudmade.core.js +383 -0
  18. data/vendor/assets/javascripts/mxn.core-min.js +15 -0
  19. data/vendor/assets/javascripts/mxn.core.js +1892 -0
  20. data/vendor/assets/javascripts/mxn.geocoder-min.js +15 -0
  21. data/vendor/assets/javascripts/mxn.geocoder.js +74 -0
  22. data/vendor/assets/javascripts/mxn.geocommons.core-min.js +15 -0
  23. data/vendor/assets/javascripts/mxn.geocommons.core.js +343 -0
  24. data/vendor/assets/javascripts/mxn.google.core-min.js +15 -0
  25. data/vendor/assets/javascripts/mxn.google.core.js +536 -0
  26. data/vendor/assets/javascripts/mxn.google.geocoder-min.js +15 -0
  27. data/vendor/assets/javascripts/mxn.google.geocoder.js +87 -0
  28. data/vendor/assets/javascripts/mxn.googleearth.core-min.js +15 -0
  29. data/vendor/assets/javascripts/mxn.googleearth.core.js +350 -0
  30. data/vendor/assets/javascripts/mxn.googlev3.core-min.js +15 -0
  31. data/vendor/assets/javascripts/mxn.googlev3.core.js +630 -0
  32. data/vendor/assets/javascripts/mxn.googlev3.geocoder-min.js +15 -0
  33. data/vendor/assets/javascripts/mxn.googlev3.geocoder.js +101 -0
  34. data/vendor/assets/javascripts/mxn.js +581 -0
  35. data/vendor/assets/javascripts/mxn.leaflet.core-min.js +15 -0
  36. data/vendor/assets/javascripts/mxn.leaflet.core.js +398 -0
  37. data/vendor/assets/javascripts/mxn.mapquest.geocoder-min.js +15 -0
  38. data/vendor/assets/javascripts/mxn.mapquest.geocoder.js +63 -0
  39. data/vendor/assets/javascripts/mxn.microsoft.core-min.js +15 -0
  40. data/vendor/assets/javascripts/mxn.microsoft.core.js +429 -0
  41. data/vendor/assets/javascripts/mxn.microsoft7.core-min.js +15 -0
  42. data/vendor/assets/javascripts/mxn.microsoft7.core.js +458 -0
  43. data/vendor/assets/javascripts/mxn.microsoft7.geocoder-min.js +15 -0
  44. data/vendor/assets/javascripts/mxn.microsoft7.geocoder.js +66 -0
  45. data/vendor/assets/javascripts/mxn.multimap.core-min.js +15 -0
  46. data/vendor/assets/javascripts/mxn.multimap.core.js +473 -0
  47. data/vendor/assets/javascripts/mxn.openlayers.core-min.js +15 -0
  48. data/vendor/assets/javascripts/mxn.openlayers.core.js +630 -0
  49. data/vendor/assets/javascripts/mxn.openlayers.geocoder-min.js +15 -0
  50. data/vendor/assets/javascripts/mxn.openlayers.geocoder.js +106 -0
  51. data/vendor/assets/javascripts/mxn.openmq.core-min.js +15 -0
  52. data/vendor/assets/javascripts/mxn.openmq.core.js +364 -0
  53. data/vendor/assets/javascripts/mxn.openspace.core-min.js +15 -0
  54. data/vendor/assets/javascripts/mxn.openspace.core.js +460 -0
  55. data/vendor/assets/javascripts/mxn.ovi.core-min.js +15 -0
  56. data/vendor/assets/javascripts/mxn.ovi.core.js +508 -0
  57. data/vendor/assets/javascripts/mxn.ovi.geocoder-min.js +15 -0
  58. data/vendor/assets/javascripts/mxn.ovi.geocoder.js +129 -0
  59. data/vendor/assets/javascripts/mxn.yahoo.core-min.js +15 -0
  60. data/vendor/assets/javascripts/mxn.yahoo.core.js +406 -0
  61. data/vendor/assets/javascripts/mxn.yandex.core-min.js +15 -0
  62. data/vendor/assets/javascripts/mxn.yandex.core.js +527 -0
  63. data/vendor/assets/javascripts/mxn.yandex.geocoder-min.js +15 -0
  64. data/vendor/assets/javascripts/mxn.yandex.geocoder.js +66 -0
  65. metadata +110 -0
@@ -0,0 +1,106 @@
1
+ /*
2
+ MAPSTRACTION v2.0.18 http://www.mapstraction.com
3
+
4
+ Copyright (c) 2012 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler, Gary Gale
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
+ */
15
+ mxn.register('openlayers', {
16
+
17
+ Geocoder: {
18
+
19
+ init: function() {
20
+ var me = this;
21
+ },
22
+
23
+ geocode: function(address){
24
+ var me = this;
25
+
26
+ if (!address.hasOwnProperty('address') || address.address === null || address.address === '') {
27
+ address.address = [ address.street, address.locality, address.region, address.country ].join(', ');
28
+ }
29
+
30
+ if (address.hasOwnProperty('lat') && address.hasOwnProperty('lon')) {
31
+ var latlon = address.toProprietary(this.api);
32
+ OpenLayers.Request.GET({
33
+ url: 'http://nominatim.openstreetmap.org/reverse',
34
+ params: {
35
+ 'lat': address.lat,
36
+ 'lon': address.lon,
37
+ 'addressdetails': 1,
38
+ 'format': 'json'
39
+ },
40
+ callback: function(request) { me.geocode_callback(JSON.parse(request.responseText), request.status); }
41
+ });
42
+ } else {
43
+ OpenLayers.Request.GET({
44
+ url: 'http://nominatim.openstreetmap.org/search',
45
+ params: {
46
+ 'q': address.address,
47
+ 'addressdetails': 1,
48
+ 'format': 'json'
49
+ },
50
+ callback: function(request) { me.geocode_callback(JSON.parse(request.responseText), request.status); }
51
+ });
52
+ }
53
+ },
54
+
55
+ geocode_callback: function(results, status){
56
+ var return_location = {};
57
+
58
+ if (status != 200) {
59
+ this.error_callback(response.statusText);
60
+ }
61
+ else {
62
+ return_location.street = '';
63
+ return_location.locality = '';
64
+ return_location.postcode = '';
65
+ return_location.region = '';
66
+ return_location.country = '';
67
+
68
+ var place;
69
+
70
+ if (results.length > 0) {
71
+ place = results[0];
72
+ } else {
73
+ place = results;
74
+ }
75
+ var street_components = [];
76
+
77
+ if (place.address.country) {
78
+ return_location.country = place.address.country;
79
+ }
80
+ if (place.address.state) {
81
+ return_location.region = place.address.state;
82
+ }
83
+ if (place.address.city) {
84
+ return_location.locality = place.address.city;
85
+ }
86
+ if (place.address.postcode) {
87
+ return_location.postcode = place.address.postcode;
88
+ }
89
+ if (place.address.road) {
90
+ street_components.push(place.address.road);
91
+ }
92
+ if (place.address.house_number) {
93
+ street_components.unshift(place.address.house_number);
94
+ }
95
+
96
+ if (return_location.street === '' && street_components.length > 0) {
97
+ return_location.street = street_components.join(' ');
98
+ }
99
+
100
+ return_location.point = new mxn.LatLonPoint(parseFloat(place.lat), parseFloat(place.lon));
101
+
102
+ this.callback(return_location);
103
+ }
104
+ }
105
+ }
106
+ });
@@ -0,0 +1,15 @@
1
+ /*
2
+ MAPSTRACTION v2.0.18 http://www.mapstraction.com
3
+
4
+ Copyright (c) 2012 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler, Gary Gale
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
+ */
15
+ mxn.register("openmq",{Mapstraction:{init:function(a,b){var c=this;var d=new MQA.TileMap(a);this.maps[b]=d;this.loaded[b]=true;MQA.withModule("shapes",function(){});MQA.EventManager.addListener(d,"click",function(f){c.click.fire()});MQA.EventManager.addListener(d,"zoomend",function(f){c.changeZoom.fire()});MQA.EventManager.addListener(d,"moveend",function(f){c.endPan.fire()})},applyOptions:function(){if(this.options.enableScrollWheelZoom){MQA.withModule("mousewheel",function(){var a=this.maps[this.api];a.enableMouseWheelZoom()})}},resizeTo:function(b,a){this.currentElement.style.width=b;this.currentElement.style.height=a},addControls:function(a){var b=this.maps[this.api];if(a.zoom){if(a.zoom=="large"){this.addLargeControls()}else{this.addSmallControls()}}},addSmallControls:function(){var a=this.maps[this.api];MQA.withModule("smallzoom",function(){a.addControl(new MQA.SmallZoom(),new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT,new MQA.Size(5,5)))})},addLargeControls:function(){var a=this.maps[this.api];MQA.withModule("largezoom",function(){a.addControl(new MQA.LargeZoom(),new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT,new MQA.Size(5,5)))})},addMapTypeControls:function(){var a=this.maps[this.api]},setCenterAndZoom:function(a,b){this.setCenter(a);this.setZoom(b)},addMarker:function(b,a){var d=this.maps[this.api];var c=b.toProprietary(this.api);d.addShape(c);return c},removeMarker:function(a){var b=this.maps[this.api];b.removeShape(a.proprietary_marker)},declutterMarkers:function(a){var b=this.maps[this.api]},addPolyline:function(b,a){var d=this.api;var c=this.maps[d];MQA.withModule("shapes",function(){var e=b.toProprietary(d);c.addShape(e)})},removePolyline:function(a){var b=this.maps[this.api]},getCenter:function(){var b=this.maps[this.api];var a=b.getCenter();return new mxn.LatLonPoint(a.lat,a.lng)},setCenter:function(a,b){var d=this.maps[this.api];var c=a.toProprietary(this.api);d.setCenter(c)},setZoom:function(a){var b=this.maps[this.api];b.setZoomLevel(a)},getZoom:function(){var b=this.maps[this.api];var a=b.getZoomLevel();return a},getZoomLevelForBoundingBox:function(e){var d=this.maps[this.api];var c=e.getNorthEast();var a=e.getSouthWest();var b;return b},setMapType:function(a){var b=this.maps[this.api];b.setMapType("map")},getMapType:function(){var a=this.maps[this.api];return mxn.Mapstraction.ROAD},getBounds:function(){var d=this.maps[this.api];var b=d.getBounds();var c=b.lr;var a=b.ul;return new mxn.BoundingBox(c.lat,a.lng,a.lat,c.lng)},setBounds:function(c){var e=this.maps[this.api];var a=c.getSouthWest();var d=c.getNorthEast();var b=new MQA.RectLL(new MQA.LatLng(a.lat,d.lon),new MQA.LatLng(d.lat,a.lon));e.zoomToRect(b)},addImageOverlay:function(c,a,e,i,f,g,d,h){var b=this.maps[this.api]},setImagePosition:function(e,b){var d=this.maps[this.api];var c;var a},addOverlay:function(a,b){var c=this.maps[this.api]},addTileLayer:function(g,a,c,e,f,b){var d=this.maps[this.api]},toggleTileLayer:function(b){var a=this.maps[this.api]},getPixelRatio:function(){var a=this.maps[this.api]},mousePosition:function(a){var b=this.maps[this.api]}},LatLonPoint:{toProprietary:function(){return new MQA.LatLng(this.lat,this.lon)},fromProprietary:function(a){this.lat=a.lat;this.lon=a.lng}},Marker:{toProprietary:function(){var c=this.location.toProprietary(this.api);var a=new MQA.Poi(c);if(this.iconUrl){var b=new MQA.Icon(this.iconUrl,this.iconSize[0],this.iconSize[1]);a.setIcon(b)}if(this.infoBubble){a.setInfoContentHTML(this.infoBubble)}MQA.EventManager.addListener(a,"click",function(){a.mapstraction_marker.click.fire()});return a},openBubble:function(){},hide:function(){},show:function(){},update:function(){}},Polyline:{toProprietary:function(){var c=[];var f=this.points;for(var b=0,d=this.points.length;b<d;b++){var e=this.points[b];c.push(e.lat);c.push(e.lon)}var a=new MQA.LineOverlay();a.setShapePoints(c);a.color=this.color||"#000000";a.colorAlpha=this.opacity||1;a.borderWidth=this.width||3;return a},show:function(){},hide:function(){}}});
@@ -0,0 +1,364 @@
1
+ /*
2
+ MAPSTRACTION v2.0.18 http://www.mapstraction.com
3
+
4
+ Copyright (c) 2012 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler, Gary Gale
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
+ */
15
+ mxn.register('openmq', {
16
+
17
+ Mapstraction: {
18
+
19
+ init: function(element, api) {
20
+ var me = this;
21
+ var map = new MQA.TileMap(element);
22
+ this.maps[api] = map;
23
+ this.loaded[api] = true;
24
+
25
+ MQA.withModule('shapes', function() {
26
+ // Loading all modules that can't be loaded on-demand
27
+ // [This space left intentionally blank]
28
+ });
29
+
30
+ MQA.EventManager.addListener(map, 'click', function(e) {
31
+ me.click.fire();
32
+ });
33
+
34
+ MQA.EventManager.addListener(map, 'zoomend', function(e) {
35
+ me.changeZoom.fire();
36
+ });
37
+
38
+ MQA.EventManager.addListener(map, 'moveend', function(e) {
39
+ me.endPan.fire();
40
+ });
41
+
42
+ },
43
+
44
+ applyOptions: function(){
45
+ if (this.options.enableScrollWheelZoom) {
46
+ MQA.withModule('mousewheel', function() {
47
+ var map = this.maps[this.api];
48
+ map.enableMouseWheelZoom();
49
+ });
50
+ }
51
+ },
52
+
53
+ resizeTo: function(width, height){
54
+ this.currentElement.style.width = width;
55
+ this.currentElement.style.height = height;
56
+ },
57
+
58
+ addControls: function( args ) {
59
+ var map = this.maps[this.api];
60
+
61
+ if (args.zoom) {
62
+ if (args.zoom == 'large') {
63
+ this.addLargeControls();
64
+ } else {
65
+ this.addSmallControls();
66
+ }
67
+ }
68
+ },
69
+
70
+ addSmallControls: function() {
71
+ var map = this.maps[this.api];
72
+ MQA.withModule('smallzoom', function() {
73
+ map.addControl(
74
+ new MQA.SmallZoom(),
75
+ new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT, new MQA.Size(5,5))
76
+ );
77
+ });
78
+ },
79
+
80
+ addLargeControls: function() {
81
+ var map = this.maps[this.api];
82
+ MQA.withModule('largezoom', function() {
83
+ map.addControl(
84
+ new MQA.LargeZoom(),
85
+ new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT, new MQA.Size(5,5))
86
+ );
87
+ });
88
+ },
89
+
90
+ addMapTypeControls: function() {
91
+ var map = this.maps[this.api];
92
+ // Open MapQuest only supports a single map type, so there is no map type control
93
+ },
94
+
95
+ setCenterAndZoom: function(point, zoom) {
96
+ this.setCenter(point);
97
+ this.setZoom(zoom);
98
+ },
99
+
100
+ addMarker: function(marker, old) {
101
+ var map = this.maps[this.api];
102
+ var pin = marker.toProprietary(this.api);
103
+
104
+ map.addShape(pin);
105
+
106
+ return pin;
107
+ },
108
+
109
+ removeMarker: function(marker) {
110
+ var map = this.maps[this.api];
111
+ map.removeShape(marker.proprietary_marker);
112
+ },
113
+
114
+ declutterMarkers: function(opts) {
115
+ var map = this.maps[this.api];
116
+ // TODO: Add provider code
117
+ },
118
+
119
+ addPolyline: function(polyline, old) {
120
+ var thisapi = this.api;
121
+ var map = this.maps[thisapi];
122
+ MQA.withModule('shapes', function() {
123
+ var pl = polyline.toProprietary(thisapi);
124
+ map.addShape(pl);
125
+ });
126
+ },
127
+
128
+ removePolyline: function(polyline) {
129
+ var map = this.maps[this.api];
130
+
131
+ // TODO: Add provider code
132
+ },
133
+
134
+ getCenter: function() {
135
+ var map = this.maps[this.api];
136
+ var point = map.getCenter();
137
+
138
+ return new mxn.LatLonPoint(point.lat, point.lng);
139
+ },
140
+
141
+ setCenter: function(point, options) {
142
+ var map = this.maps[this.api];
143
+ var pt = point.toProprietary(this.api);
144
+ map.setCenter(pt);
145
+ },
146
+
147
+ setZoom: function(zoom) {
148
+ var map = this.maps[this.api];
149
+ map.setZoomLevel(zoom);
150
+ },
151
+
152
+ getZoom: function() {
153
+ var map = this.maps[this.api];
154
+ var zoom = map.getZoomLevel();
155
+
156
+ return zoom;
157
+ },
158
+
159
+ getZoomLevelForBoundingBox: function( bbox ) {
160
+ var map = this.maps[this.api];
161
+ // NE and SW points from the bounding box.
162
+ var ne = bbox.getNorthEast();
163
+ var sw = bbox.getSouthWest();
164
+ var zoom;
165
+
166
+ // TODO: Add provider code
167
+
168
+ return zoom;
169
+ },
170
+
171
+ setMapType: function(type) {
172
+ var map = this.maps[this.api];
173
+ // MapQuest has a function to set map type, but open MapQuest only supports road
174
+ /*
175
+ switch (type) {
176
+ case mxn.Mapstraction.SATELLITE:
177
+ map.setMapType('sat');
178
+ break;
179
+ case mxn.Mapstraction.HYBRID:
180
+ map.setMapType('hyb');
181
+ break;
182
+ //case mxn.Mapstraction.ROAD:
183
+ // break;
184
+ default:
185
+ map.setMapType('map');
186
+ break;
187
+ }
188
+ */
189
+ map.setMapType('map');
190
+ },
191
+
192
+ getMapType: function() {
193
+ var map = this.maps[this.api];
194
+
195
+ /*
196
+ var type = map.getMapType();
197
+ switch(type) {
198
+ case 'sat':
199
+ return mxn.Mapstraction.SATELLITE;
200
+ case 'hyb':
201
+ return mxn.Mapstraction.HYBRID;
202
+ case 'map':
203
+ default:
204
+ return mxn.Mapstraction.ROAD
205
+ }
206
+ */
207
+ return mxn.Mapstraction.ROAD;
208
+ },
209
+
210
+ getBounds: function () {
211
+ var map = this.maps[this.api];
212
+ var rect = map.getBounds();
213
+ var se = rect.lr;
214
+ var nw = rect.ul;
215
+ // MapQuest uses SE and NW points to declare bounds
216
+ return new mxn.BoundingBox(se.lat, nw.lng, nw.lat, se.lng);
217
+ },
218
+
219
+ setBounds: function(bounds){
220
+ var map = this.maps[this.api];
221
+ var sw = bounds.getSouthWest();
222
+ var ne = bounds.getNorthEast();
223
+
224
+ // MapQuest uses SE and NW points to declare bounds
225
+ var rect = new MQA.RectLL(new MQA.LatLng(sw.lat, ne.lon), new MQA.LatLng(ne.lat, sw.lon));
226
+ map.zoomToRect(rect);
227
+ },
228
+
229
+ addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
230
+ var map = this.maps[this.api];
231
+
232
+ // TODO: Add provider code
233
+ },
234
+
235
+ setImagePosition: function(id, oContext) {
236
+ var map = this.maps[this.api];
237
+ var topLeftPoint; var bottomRightPoint;
238
+
239
+ // TODO: Add provider code
240
+
241
+ //oContext.pixels.top = ...;
242
+ //oContext.pixels.left = ...;
243
+ //oContext.pixels.bottom = ...;
244
+ //oContext.pixels.right = ...;
245
+ },
246
+
247
+ addOverlay: function(url, autoCenterAndZoom) {
248
+ var map = this.maps[this.api];
249
+
250
+ // TODO: Add provider code
251
+
252
+ },
253
+
254
+ addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom, map_type) {
255
+ var map = this.maps[this.api];
256
+
257
+ // TODO: Add provider code
258
+ },
259
+
260
+ toggleTileLayer: function(tile_url) {
261
+ var map = this.maps[this.api];
262
+
263
+ // TODO: Add provider code
264
+ },
265
+
266
+ getPixelRatio: function() {
267
+ var map = this.maps[this.api];
268
+
269
+ // TODO: Add provider code
270
+ },
271
+
272
+ mousePosition: function(element) {
273
+ var map = this.maps[this.api];
274
+
275
+ // TODO: Add provider code
276
+ }
277
+ },
278
+
279
+ LatLonPoint: {
280
+
281
+ toProprietary: function() {
282
+ return new MQA.LatLng(this.lat, this.lon);
283
+ },
284
+
285
+ fromProprietary: function(mqPoint) {
286
+ this.lat = mqPoint.lat;
287
+ this.lon = mqPoint.lng;
288
+ }
289
+ },
290
+
291
+ Marker: {
292
+
293
+ toProprietary: function() {
294
+ var pt = this.location.toProprietary(this.api);
295
+ var mk = new MQA.Poi(pt);
296
+
297
+ if (this.iconUrl) {
298
+ var icon = new MQA.Icon(this.iconUrl, this.iconSize[0], this.iconSize[1]);
299
+ mk.setIcon(icon);
300
+ }
301
+
302
+ if (this.infoBubble) {
303
+ mk.setInfoContentHTML(this.infoBubble);
304
+ }
305
+
306
+ MQA.EventManager.addListener(mk, 'click', function() {
307
+ mk.mapstraction_marker.click.fire();
308
+ });
309
+
310
+ return mk;
311
+ },
312
+
313
+ openBubble: function() {
314
+ // TODO: Add provider code
315
+ },
316
+
317
+ hide: function() {
318
+ // TODO: Add provider code
319
+ },
320
+
321
+ show: function() {
322
+ // TODO: Add provider code
323
+ },
324
+
325
+ update: function() {
326
+ // TODO: Add provider code
327
+ }
328
+
329
+ },
330
+
331
+ Polyline: {
332
+
333
+ toProprietary: function() {
334
+ var points = [];
335
+ var oldpoints = this.points;
336
+
337
+ for(var i =0, length = this.points.length; i < length; i++) {
338
+ var thispt = this.points[i];
339
+ points.push(thispt.lat);
340
+ points.push(thispt.lon);
341
+ }
342
+
343
+ var line = new MQA.LineOverlay();
344
+ line.setShapePoints(points);
345
+
346
+ // Line options
347
+ line.color = this.color || '#000000';
348
+ line.colorAlpha = this.opacity || 1.0;
349
+ line.borderWidth = this.width || 3;
350
+
351
+ return line;
352
+ },
353
+
354
+ show: function() {
355
+ // TODO: Add provider code
356
+ },
357
+
358
+ hide: function() {
359
+ // TODO: Add provider code
360
+ }
361
+
362
+ }
363
+
364
+ });
@@ -0,0 +1,15 @@
1
+ /*
2
+ MAPSTRACTION v2.0.18 http://www.mapstraction.com
3
+
4
+ Copyright (c) 2012 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler, Gary Gale
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
+ */
15
+ mxn.register("openspace",{Mapstraction:{init:function(a,b){var c=this;this.maps[b]=new OpenSpace.Map(a,{controls:[],centreInfoWindow:false});this.maps[b].addControl(new OpenLayers.Control.Navigation());this.maps[b].addControl(new OpenLayers.Control.KeyboardDefaults());this.maps[b].addControl(new OpenSpace.Control.CopyrightCollection());this.maps[b].events.register("click",this.maps[b],function(e){var d=this.getLonLatFromViewPortPx(e.xy);var f=new mxn.LatLonPoint();f.fromProprietary(this.api,d);c.clickHandler(f.lat,f.lon);return false});this.loaded[b]=true},applyOptions:function(){var a=this.maps[this.api]},resizeTo:function(b,a){this.currentElement.style.width=b;this.currentElement.style.height=a;this.maps[this.api].updateSize()},addControls:function(b){var d=this.maps[this.api];for(var c=d.controls.length;c>3;c--){d.controls[c-1].deactivate();d.removeControl(d.controls[c-1])}if(b.zoom=="large"){d.addControl(new OpenSpace.Control.LargeMapControl())}else{if(b.zoom=="small"||b.pan){d.addControl(new OpenSpace.Control.SmallMapControl())}}if(b.overview){var a=new OpenSpace.Control.OverviewMap();d.addControl(a);a.maximizeControl()}if(b.map_type){d.addControl(new OpenLayers.Control.LayerSwitcher())}},addSmallControls:function(){var a=this.maps[this.api];a.addControl(new OpenSpace.Control.SmallMapControl())},addLargeControls:function(){var a=this.maps[this.api];a.addControl(new OpenSpace.Control.LargeMapControl())},addMapTypeControls:function(){var a=this.maps[this.api]},setCenterAndZoom:function(a,c){var e=this.maps[this.api];var d=a.toProprietary(this.api);var b=c-6;if(b<0){b=0}else{if(b>10){b=10}}e.setCenter(d,b)},addMarker:function(b,a){var d=this.maps[this.api];var c=b.toProprietary(this.api);d.addOverlay(c);return c},removeMarker:function(a){var b=this.maps[this.api]},declutterMarkers:function(a){var b=this.maps[this.api]},addPolyline:function(b,a){var d=this.maps[this.api];var c=b.toProprietary(this.api);return c},removePolyline:function(a){var b=this.maps[this.api]},getCenter:function(){var a;var c=this.maps[this.api];var b=c.getCenter();a=new mxn.LatLonPoint();a.fromOpenSpace(b);return a},setCenter:function(a,b){var d=this.maps[this.api];var c=a.toProprietary(this.api);if(b&&b.pan){d.setCenter(c.toProprietary(this.api))}else{d.setCenter(c.toProprietary(this.api))}},setZoom:function(b){var c=this.maps[this.api];var a=b-6;if(a<0){a=0}else{if(a>10){a=10}}c.zoomTo(a)},getZoom:function(){var b=this.maps[this.api];var a;a=b.zoom+6;return a},getZoomLevelForBoundingBox:function(f){var e=this.maps[this.api];var d=f.getNorthEast();var a=f.getSouthWest();var c;var b=new OpenSpace.MapBounds();b.extend(new mxn.LatLonPoint(a.lat,a.lon).toProprietary(this.api));b.extend(new mxn.LatLonPoint(d.lat,d.lon).toProprietary(this.api));c=e.getZoomForExtent(b)+6;return c},setMapType:function(a){var b=this.maps[this.api];switch(a){case mxn.Mapstraction.ROAD:break;case mxn.Mapstraction.SATELLITE:break;case mxn.Mapstraction.HYBRID:break;default:}},getMapType:function(){var a=this.maps[this.api]},getBounds:function(){var e=this.maps[this.api];var c=e.calculateBounds().toArray();var f=new OpenSpace.MapPoint(c[0],c[1]);var b=new OpenSpace.MapPoint(c[2],c[3]);var a=new mxn.LatLonPoint();a.fromOpenSpace(f);var d=new mxn.LatLonPoint();d.fromOpenSpace(b);return new mxn.BoundingBox(a.lat,a.lon,d.lat,d.lon)},setBounds:function(c){var e=this.maps[this.api];var a=c.getSouthWest();var d=c.getNorthEast();var b=new OpenSpace.MapBounds();b.extend(new mxn.LatLonPoint(a.lat,a.lon).toProprietary(this.api));b.extend(new mxn.LatLonPoint(d.lat,d.lon).toProprietary(this.api));e.zoomToExtent(b)},addImageOverlay:function(c,a,e,i,f,g,d,h){var b=this.maps[this.api]},setImagePosition:function(e,b){var d=this.maps[this.api];var c;var a},addOverlay:function(a,b){var c=this.maps[this.api]},addTileLayer:function(f,a,b,d,e){var c=this.maps[this.api]},toggleTileLayer:function(b){var a=this.maps[this.api]},getPixelRatio:function(){var a=this.maps[this.api]},mousePosition:function(b){var c=this.maps[this.api];try{c.events.register("mousemove",c,function(g){var d=c.getLonLatFromViewPortPx(g.xy);var i=d.lon*(180/20037508.34);var f=d.lat*(180/20037508.34);f=(180/Math.PI)*(2*Math.atan(Math.exp(f*Math.PI/180))-(Math.PI/2));var h=numFormatFloat(f,4)+" / "+numFormatFloat(i,4);locDisp.innerHTML=h});locDisp.innerHTML="0.0000 / 0.0000"}catch(a){alert("Error: "+a)}}},LatLonPoint:{toProprietary:function(){var b=new OpenLayers.LonLat(this.lon,this.lat);var a=new OpenSpace.GridProjection();return a.getMapPointFromLonLat(b)},fromProprietary:function(c){var b=new OpenSpace.GridProjection();var a=b.getLonLatFromMapPoint(c);this.lon=a.lon;this.lat=a.lat}},Marker:{toProprietary:function(){var c,b,d;if(this.iconSize){c=new OpenLayers.Size(this.iconSize[0],this.iconSize[1])}else{c=new OpenLayers.Size(20,25)}if(this.iconAnchor){b=new OpenLayers.Pixel(this.iconAnchor[0],this.iconAnchor[1])}else{b=new OpenLayers.Pixel(-(c.w/2),-c.h)}if(this.iconUrl){d=new OpenSpace.Icon(this.iconUrl,c,b)}else{}OpenLayers.Marker.Label(this.location.toProprietary(this.api),d,this.labelText,{mouseOver:true,tooltipsFormat:true});var a=new OpenLayers.Marker(this.location.toProprietary(this.api),d);return a},openBubble:function(){},hide:function(){},show:function(){},update:function(){}},Polyline:{toProprietary:function(){var c;var b=[];for(var d=0,e=this.points.length;d<e;d++){var a=this.points[d].toProprietary(this.api);var f=new OpenLayers.Geometry.Point(a.getEasting(),a.getNorthing());b.push(f)}if(this.closed){c=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LinearRing(b),null,{fillColor:this.color,strokeColor:this.color,strokeOpacity:this.opacity,fillOpacity:this.opacity,strokeWidth:this.width})}else{c=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(b),null,{fillColor:0,strokeColor:this.color,strokeOpacity:this.opacity,fillOpacity:0,strokeWidth:this.width})}return c},show:function(){},hide:function(){}}});