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,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
+ (function(){var b=function(){this.invoker.go("init")};var a=mxn.Geocoder=function(d,e,c){this.api=d;this.geocoders={};this.callback=e;this.error_callback=c||function(){};this.invoker=new mxn.Invoker(this,"Geocoder",function(){return this.api});b.apply(this)};mxn.addProxyMethods(a,["geocode","geocode_callback"]);a.prototype.swap=function(c){if(this.api==c){return}this.api=c;if(!this.geocoders.hasOwnProperty(this.api)){b.apply(this)}}})();
@@ -0,0 +1,74 @@
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
+ (function(){
16
+
17
+ /**
18
+ * Initialise our provider. This function should only be called
19
+ * from within mapstraction code, not exposed as part of the API.
20
+ * @private
21
+ */
22
+ var init = function() {
23
+ this.invoker.go('init');
24
+ };
25
+
26
+ /**
27
+ * Geocoder instantiates a geocoder with some API choice
28
+ * @name mxn.Geocoder
29
+ * @constructor
30
+ * @param {String} api The API to use, currently only 'mapquest' is supported
31
+ * @param {Function} callback The function to call when a geocode request returns (function(waypoint))
32
+ * @param {Function} error_callback The optional function to call when a geocode request fails
33
+ * @exports Geocoder as mxn.Geocoder
34
+ */
35
+ var Geocoder = mxn.Geocoder = function (api, callback, error_callback) {
36
+ this.api = api;
37
+ this.geocoders = {};
38
+ this.callback = callback;
39
+ this.error_callback = error_callback || function(){};
40
+
41
+ // set up our invoker for calling API methods
42
+ this.invoker = new mxn.Invoker(this, 'Geocoder', function(){ return this.api; });
43
+ init.apply(this);
44
+ };
45
+
46
+ mxn.addProxyMethods(Geocoder, [
47
+
48
+ /**
49
+ * Geocodes the provided address.
50
+ * @name mxn.Geocoder#geocode
51
+ * @function
52
+ * @param {Object} address Address hash, keys are: street, locality, region, country.
53
+ */
54
+ 'geocode',
55
+
56
+ 'geocode_callback'
57
+
58
+ ]);
59
+
60
+ /**
61
+ * Change the geocoding API in use
62
+ * @name mxn.Geocoder#swap
63
+ * @param {String} api The API to swap to
64
+ */
65
+ Geocoder.prototype.swap = function(api) {
66
+ if (this.api == api) { return; }
67
+
68
+ this.api = api;
69
+ if (!this.geocoders.hasOwnProperty(this.api)) {
70
+ init.apply(this);
71
+ }
72
+ };
73
+
74
+ })();
@@ -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("geocommons",{Mapstraction:{init:function(a,b){var c=this;this.element=a;this.loaded[this.api]=false;this.maps[b]=new F1.Maker.Map({dom_id:this.element.id,map_id:143049,uiLayers:false,flashvars:{},onMapLoaded:function(e){c.loaded[c.api]=true;var f=c.onload[c.api].length;for(var d=0;d<f;d++){c.onload[c.api][d]()}c.load.fire()},onMapPanStop:function(){c.endPan.fire()},onMapZoomed:function(){c.changeZoom.fire()},onFeatureSelected:function(){c.click.fire()}})},applyOptions:function(){var a=this.maps[this.api]},resizeTo:function(b,a){var c=this.maps[this.api];c.setSize(b,a)},addControls:function(a){var b=this.maps[this.api];b.setMapStyle({zoom:{visible:a.zoom||false,expanded:(a.zoom=="large")}});b.setMapStyle({layers:{visible:a.layers||false}});b.setMapStyle({legend:{visible:a.legend||false,expanded:true}})},addSmallControls:function(){var a=this.maps[this.api];this.addControls({zoom:"small",legend:"open"})},addLargeControls:function(){var a=this.maps[this.api];this.addControls({zoom:"large",layers:true,legend:"open"})},addMapTypeControls:function(){var a=this.maps[this.api]},dragging:function(a){var b=this.maps[this.api]},setCenterAndZoom:function(a,b){var c=this.maps[this.api];c.setCenterZoom(a.lat,a.lon,b)},getCenter:function(){var b=this.maps[this.api];var a=b.getCenterZoom()[0];return new mxn.LatLonPoint(a.lat,a.lon)},setCenter:function(a,b){var c=this.maps[this.api];c.setCenter(a.lat,a.lon)},setZoom:function(a){var b=this.maps[this.api];b.setZoom(a)},getZoom:function(){var a=this.maps[this.api];return a.getZoom()},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];switch(a){case mxn.Mapstraction.ROAD:b.setBasemap("openstreetmap");break;case mxn.Mapstraction.SATELLITE:b.setBasemap("nasabluemarble");break;case mxn.Mapstraction.TERRAIN:b.setBasemap("acetateterrain");break;case mxn.Mapstraction.HYBRID:b.setBasemap("googlehybrid");break;default:b.setBasemap(a)}},getMapType:function(){var a=this.maps[this.api];switch(a.getBasemap().name){case"openstreetmap":return mxn.Mapstraction.ROAD;case"nasabluemarble":return mxn.Mapstraction.SATELLITE;case"acetateterrain":return mxn.Mapstraction.TERRAIN;case"googlehybrid":return mxn.Mapstraction.HYBRID;default:return null}},getBounds:function(){var b=this.maps[this.api];var a=b.getExtent();return new mxn.BoundingBox(a.northWest.lat,a.southEast.lon,a.southEast.lat,a.northWest.lon)},setBounds:function(b){var d=this.maps[this.api];var a=b.getSouthWest();var c=b.getNorthEast();d.setExtent(a.lon,a.lat,c.lon,c.lat)},addImageOverlay:function(c,a,e,i,f,g,d,h){var b=this.maps[this.api]},addOverlay:function(b,c){var d=this.maps[this.api];var a;if(typeof(b)==="number"){d.loadMap(b);return}a=b.match(/^(\d+)$/);if(a!==null){a=b.match(/^.*?maps\/(\d+)(\?\(\[?(.*?)\]?\))?$/)}d.loadMap(a[1])},addTileLayer:function(f,a,b,d,e){var c=this.maps[this.api];c.addLayer({source:"tile:"+f,styles:{fill:{opacity:a||1}}})},toggleTileLayer:function(d){var c=this.maps[this.api];var b=c.getLayers();for(var a=0;a<b.length;++a){if(b[a].source=="tile:"+d){c.showLayer(b[a].guid,!b[a].visible)}}},getPixelRatio:function(){var a=this.maps[this.api]},mousePosition:function(a){var b=this.maps[this.api]},addMarker:function(b,a){var f=this.maps[this.api];var c=b.toProprietary(this.api);var e=f.getLayers();for(var d=0;d<e.length;++d){if(e[d].title=="Edit Layer"){f.addFeatures(e[d].guid,[c],false);f.addLayerInfoWindowFilter(e[d].guid,{title:"$[title]",tabs:[{type:"text",title:"About",value:"$[infoBubble]"}]})}}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]}},LatLonPoint:{toProprietary:function(){return{type:"Point",coordinates:[this.lon,this.lat]}},fromProprietary:function(a){this.lon=a.coordinates[0];this.lat=a.coordinates[1]}},Marker:{toProprietary:function(){return{title:this.labelText||"",infoBubble:this.infoBubble||"",geometry:this.location.toProprietary("geocommons")}},openBubble:function(){},closeBubble:function(){},hide:function(){},show:function(){},update:function(){}},Polyline:{toProprietary:function(){return{}},show:function(){},hide:function(){}}});
@@ -0,0 +1,343 @@
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('geocommons', {
16
+
17
+ Mapstraction: {
18
+
19
+ init: function(element, api) {
20
+ var me = this;
21
+ this.element = element;
22
+ this.loaded[this.api] = false; // Loading will take a little bit.
23
+
24
+ this.maps[api] = new F1.Maker.Map({
25
+ dom_id: this.element.id,
26
+ map_id: 143049,
27
+ uiLayers: false,
28
+ flashvars: {},
29
+ onMapLoaded: function(map){
30
+ me.loaded[me.api] = true;
31
+ var num_events = me.onload[me.api].length;
32
+ for (var i = 0; i < num_events; i++) {
33
+ me.onload[me.api][i]();
34
+ }
35
+ me.load.fire();
36
+ },
37
+ onMapPanStop: function() {
38
+ me.endPan.fire();
39
+ },
40
+ onMapZoomed: function() {
41
+ me.changeZoom.fire();
42
+ },
43
+ onFeatureSelected: function() {
44
+ me.click.fire();
45
+ }
46
+
47
+ });
48
+
49
+ },
50
+
51
+ applyOptions: function(){
52
+ var map = this.maps[this.api];
53
+
54
+ // TODO: Add provider code
55
+ },
56
+
57
+ resizeTo: function(width, height){
58
+ var map = this.maps[this.api];
59
+ map.setSize(width,height);
60
+ },
61
+
62
+ addControls: function( args ) {
63
+ var map = this.maps[this.api];
64
+ map.setMapStyle({zoom: {visible: args.zoom || false, expanded: (args.zoom == 'large')}});
65
+ map.setMapStyle({layers: {visible: args.layers || false}});
66
+ map.setMapStyle({legend: {visible: args.legend || false, expanded: true}});
67
+ },
68
+
69
+ addSmallControls: function() {
70
+ var map = this.maps[this.api];
71
+ this.addControls({
72
+ zoom: 'small',
73
+ legend: "open"
74
+ });
75
+
76
+ },
77
+
78
+ addLargeControls: function() {
79
+ var map = this.maps[this.api];
80
+ this.addControls({
81
+ zoom: 'large',
82
+ layers: true,
83
+ legend: "open"
84
+ });
85
+ },
86
+
87
+ addMapTypeControls: function() {
88
+ var map = this.maps[this.api];
89
+
90
+ // TODO: Add provider code
91
+ },
92
+
93
+ dragging: function(on) {
94
+ var map = this.maps[this.api];
95
+
96
+ // TODO: Add provider code
97
+ },
98
+
99
+ setCenterAndZoom: function(point, zoom) {
100
+ var map = this.maps[this.api];
101
+ map.setCenterZoom(point.lat, point.lon,zoom);
102
+ },
103
+
104
+ getCenter: function() {
105
+ var map = this.maps[this.api];
106
+ var point = map.getCenterZoom()[0];
107
+ return new mxn.LatLonPoint(point.lat,point.lon);
108
+ },
109
+
110
+ setCenter: function(point, options) {
111
+ var map = this.maps[this.api];
112
+ map.setCenter(point.lat, point.lon);
113
+ },
114
+
115
+ setZoom: function(zoom) {
116
+ var map = this.maps[this.api];
117
+ map.setZoom(zoom);
118
+ },
119
+
120
+ getZoom: function() {
121
+ var map = this.maps[this.api];
122
+ return map.getZoom();
123
+ },
124
+
125
+ getZoomLevelForBoundingBox: function( bbox ) {
126
+ var map = this.maps[this.api];
127
+ // NE and SW points from the bounding box.
128
+ var ne = bbox.getNorthEast();
129
+ var sw = bbox.getSouthWest();
130
+ var zoom;
131
+
132
+ // TODO: Add provider code
133
+
134
+ return zoom;
135
+ },
136
+
137
+ setMapType: function(type) {
138
+ var map = this.maps[this.api];
139
+ switch(type) {
140
+ case mxn.Mapstraction.ROAD:
141
+ map.setBasemap("openstreetmap");
142
+ break;
143
+ case mxn.Mapstraction.SATELLITE:
144
+ map.setBasemap("nasabluemarble");
145
+ break;
146
+ case mxn.Mapstraction.TERRAIN:
147
+ map.setBasemap("acetateterrain");
148
+ break;
149
+ case mxn.Mapstraction.HYBRID:
150
+ map.setBasemap("googlehybrid");
151
+ break;
152
+ default:
153
+ map.setBasemap(type);
154
+ }
155
+ },
156
+
157
+ getMapType: function() {
158
+ var map = this.maps[this.api];
159
+
160
+ // TODO: I don't thick this is correct -Derek
161
+ switch(map.getBasemap().name) {
162
+ case "openstreetmap":
163
+ return mxn.Mapstraction.ROAD;
164
+ case "nasabluemarble":
165
+ return mxn.Mapstraction.SATELLITE;
166
+ case "acetateterrain":
167
+ return mxn.Mapstraction.TERRAIN;
168
+ case "googlehybrid":
169
+ return mxn.Mapstraction.HYBRID;
170
+ default:
171
+ return null;
172
+ }
173
+ },
174
+
175
+ getBounds: function () {
176
+ var map = this.maps[this.api];
177
+ var extent = map.getExtent();
178
+ return new mxn.BoundingBox( extent.northWest.lat, extent.southEast.lon, extent.southEast.lat, extent.northWest.lon);
179
+ },
180
+
181
+ setBounds: function(bounds){
182
+ var map = this.maps[this.api];
183
+ var sw = bounds.getSouthWest();
184
+ var ne = bounds.getNorthEast();
185
+ map.setExtent(sw.lon,sw.lat,ne.lon,ne.lat);
186
+
187
+ },
188
+
189
+ addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
190
+ var map = this.maps[this.api];
191
+
192
+ // TODO: Add provider code
193
+ },
194
+
195
+ // URL in this case is either a Maker map ID or the full URL to the Maker Map
196
+ addOverlay: function(url, autoCenterAndZoom) {
197
+ var map = this.maps[this.api];
198
+ var match;
199
+
200
+ if(typeof(url) === "number") {
201
+ map.loadMap(url);
202
+ return;
203
+ }
204
+ // Try if we've been given either a string of the ID or a URL
205
+ match = url.match(/^(\d+)$/);
206
+ if(match !== null){
207
+ match = url.match(/^.*?maps\/(\d+)(\?\(\[?(.*?)\]?\))?$/);
208
+ }
209
+
210
+ map.loadMap(match[1]);
211
+ },
212
+
213
+ addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
214
+ var map = this.maps[this.api];
215
+
216
+ map.addLayer({source: "tile:" + tile_url, styles: {fill: {opacity: opacity || 1.0}}});
217
+ },
218
+
219
+ toggleTileLayer: function(tile_url) {
220
+ var map = this.maps[this.api];
221
+
222
+ var layers = map.getLayers();
223
+ for(var i = 0; i < layers.length; ++i) {
224
+ if(layers[i].source == "tile:" + tile_url) {
225
+ map.showLayer(layers[i].guid, !layers[i].visible);
226
+ }
227
+ }
228
+ },
229
+
230
+ getPixelRatio: function() {
231
+ var map = this.maps[this.api];
232
+
233
+ // TODO: Add provider code
234
+ },
235
+
236
+ mousePosition: function(element) {
237
+ var map = this.maps[this.api];
238
+
239
+ // TODO: Add provider code
240
+ },
241
+ addMarker: function(marker, old) {
242
+ var map = this.maps[this.api];
243
+ var pin = marker.toProprietary(this.api);
244
+ // TODO: Add provider code
245
+ // map.addOverlay(pin);
246
+ var layers = map.getLayers();
247
+ for(var i = 0; i < layers.length; ++i) {
248
+ if(layers[i].title == "Edit Layer") {
249
+ map.addFeatures(layers[i].guid, [pin], false);
250
+ map.addLayerInfoWindowFilter(layers[i].guid, {title: "$[title]", tabs: [{type: "text", title: "About", value: "$[infoBubble]"}]});
251
+ }
252
+ }
253
+
254
+ return pin;
255
+ },
256
+
257
+ removeMarker: function(marker) {
258
+ var map = this.maps[this.api];
259
+ // TODO: Add provider code
260
+
261
+ },
262
+
263
+ declutterMarkers: function(opts) {
264
+ var map = this.maps[this.api];
265
+
266
+ // TODO: Add provider code
267
+ },
268
+
269
+ addPolyline: function(polyline, old) {
270
+ var map = this.maps[this.api];
271
+ var pl = polyline.toProprietary(this.api);
272
+ // TODO: Add provider code
273
+ // map.addOverlay(pl);
274
+ return pl;
275
+ },
276
+
277
+ removePolyline: function(polyline) {
278
+ var map = this.maps[this.api];
279
+ // TODO: Add provider code
280
+ }
281
+
282
+ },
283
+
284
+ LatLonPoint: {
285
+
286
+ toProprietary: function() {
287
+ // GeoJSON
288
+ return {type: "Point", coordinates: [this.lon,this.lat]};
289
+ },
290
+
291
+ fromProprietary: function(point) {
292
+ this.lon = point.coordinates[0];
293
+ this.lat = point.coordinates[1];
294
+ }
295
+
296
+ },
297
+
298
+ Marker: {
299
+
300
+ toProprietary: function() {
301
+ return {title: this.labelText || "", infoBubble: this.infoBubble || "", geometry: this.location.toProprietary('geocommons')};
302
+ },
303
+
304
+ openBubble: function() {
305
+ // TODO: Add provider code
306
+ },
307
+ closeBubble: function() {
308
+ // TODO: Add provider code
309
+ },
310
+
311
+
312
+ hide: function() {
313
+ // TODO: Add provider code
314
+ },
315
+
316
+ show: function() {
317
+ // TODO: Add provider code
318
+ },
319
+
320
+ update: function() {
321
+ // TODO: Add provider code
322
+ }
323
+
324
+ },
325
+
326
+ Polyline: {
327
+
328
+ toProprietary: function() {
329
+ return {};
330
+ // TODO: Add provider code
331
+ },
332
+
333
+ show: function() {
334
+ // TODO: Add provider code
335
+ },
336
+
337
+ hide: function() {
338
+ // TODO: Add provider code
339
+ }
340
+
341
+ }
342
+
343
+ });
@@ -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("google",{Mapstraction:{init:function(a,b){var d=this;if(GMap2){if(GBrowserIsCompatible()){this.maps[b]=new GMap2(a);GEvent.addListener(this.maps[b],"click",function(f,e){if(f&&f.mapstraction_marker){f.mapstraction_marker.click.fire()}else{if(e){d.click.fire({location:new mxn.LatLonPoint(e.y,e.x)})}}if(e){d.clickHandler(e.y,e.x,e,d)}});GEvent.addListener(this.maps[b],"moveend",function(){d.moveendHandler(d);d.endPan.fire()});GEvent.addListener(this.maps[b],"zoomend",function(){d.changeZoom.fire()});this.loaded[b]=true;d.load.fire()}else{alert("browser not compatible with Google Maps")}}else{alert(b+" map script not imported")}},applyOptions:function(){var a=this.maps[this.api];if(this.options.enableScrollWheelZoom){a.enableContinuousZoom();a.enableScrollWheelZoom()}if(this.options.enableDragging){a.enableDragging()}else{a.disableDragging()}},resizeTo:function(b,a){this.currentElement.style.width=b;this.currentElement.style.height=a;this.maps[this.api].checkResize()},addControls:function(a){var b=this.maps[this.api];if(this.controls){while((ctl=this.controls.pop())){b.removeControl(ctl)}}else{this.controls=[]}c=this.controls;if(a.zoom||a.pan){if(a.zoom=="large"){this.addLargeControls()}else{this.addSmallControls()}}if(a.scale){this.controls.unshift(new GScaleControl());b.addControl(this.controls[0]);this.addControlsArgs.scale=true}if(a.overview){c.unshift(new GOverviewMapControl());b.addControl(c[0]);this.addControlsArgs.overview=true}if(a.map_type){this.addMapTypeControls()}},addSmallControls:function(){var a=this.maps[this.api];this.controls.unshift(new GSmallMapControl());a.addControl(this.controls[0]);this.addControlsArgs.zoom="small";this.addControlsArgs.pan=true},addLargeControls:function(){var a=this.maps[this.api];this.controls.unshift(new GLargeMapControl());a.addControl(this.controls[0]);this.addControlsArgs.zoom="large";this.addControlsArgs.pan=true},addMapTypeControls:function(){var a=this.maps[this.api];this.controls.unshift(new GMapTypeControl());a.addControl(this.controls[0]);this.addControlsArgs.map_type=true},setCenterAndZoom:function(a,b){var e=this.maps[this.api];var d=a.toProprietary(this.api);e.setCenter(d,b)},addMarker:function(b,a){var e=this.maps[this.api];var d=b.toProprietary(this.api);e.addOverlay(d);GEvent.addListener(d,"infowindowopen",function(){b.openInfoBubble.fire()});GEvent.addListener(d,"infowindowclose",function(){b.closeInfoBubble.fire()});return d},removeMarker:function(a){var b=this.maps[this.api];b.removeOverlay(a.proprietary_marker)},declutterMarkers:function(a){throw"Not supported"},addPolyline:function(b,a){var d=this.maps[this.api];gpolyline=b.toProprietary(this.api);d.addOverlay(gpolyline);return gpolyline},removePolyline:function(a){var b=this.maps[this.api];b.removeOverlay(a.proprietary_polyline)},getCenter:function(){var d=this.maps[this.api];var b=d.getCenter();var a=new mxn.LatLonPoint(b.lat(),b.lng());return a},setCenter:function(a,b){var e=this.maps[this.api];var d=a.toProprietary(this.api);if(b&&b.pan){e.panTo(d)}else{e.setCenter(d)}},setZoom:function(a){var b=this.maps[this.api];b.setZoom(a)},getZoom:function(){var a=this.maps[this.api];return a.getZoom()},getZoomLevelForBoundingBox:function(g){var f=this.maps[this.api];var e=g.getNorthEast();var a=g.getSouthWest();var b=new GLatLngBounds(a.toProprietary(this.api),e.toProprietary(this.api));var d=f.getBoundsZoomLevel(b);return d},setMapType:function(a){var b=this.maps[this.api];switch(a){case mxn.Mapstraction.ROAD:b.setMapType(G_NORMAL_MAP);break;case mxn.Mapstraction.SATELLITE:b.setMapType(G_SATELLITE_MAP);break;case mxn.Mapstraction.HYBRID:b.setMapType(G_HYBRID_MAP);break;case mxn.Mapstraction.PHYSICAL:b.setMapType(G_PHYSICAL_MAP);break;default:b.setMapType(a||G_NORMAL_MAP)}},getMapType:function(){var b=this.maps[this.api];var a=b.getCurrentMapType();switch(a){case G_NORMAL_MAP:return mxn.Mapstraction.ROAD;case G_SATELLITE_MAP:return mxn.Mapstraction.SATELLITE;case G_HYBRID_MAP:return mxn.Mapstraction.HYBRID;case G_PHYSICAL_MAP:return mxn.Mapstraction.PHYSICAL;default:return null}},getBounds:function(){var g=this.maps[this.api];var f,a,b,e;var d=g.getBounds();a=d.getSouthWest();f=d.getNorthEast();return new mxn.BoundingBox(a.lat(),a.lng(),f.lat(),f.lng())},setBounds:function(b){var e=this.maps[this.api];var a=b.getSouthWest();var d=b.getNorthEast();var f=new GLatLngBounds(new GLatLng(a.lat,a.lon),new GLatLng(d.lat,d.lon));e.setCenter(f.getCenter(),e.getBoundsZoomLevel(f))},addImageOverlay:function(d,a,f,j,g,h,e,i){var b=this.maps[this.api];b.getPane(G_MAP_MAP_PANE).appendChild(i.imgElm);this.setImageOpacity(d,f);this.setImagePosition(d);GEvent.bind(b,"zoomend",this,function(){this.setImagePosition(d)});GEvent.bind(b,"moveend",this,function(){this.setImagePosition(d)})},setImagePosition:function(f,b){var e=this.maps[this.api];var d;var a;d=e.fromLatLngToDivPixel(new GLatLng(b.latLng.top,b.latLng.left));a=e.fromLatLngToDivPixel(new GLatLng(b.latLng.bottom,b.latLng.right));b.pixels.top=d.y;b.pixels.left=d.x;b.pixels.bottom=a.y;b.pixels.right=a.x},addOverlay:function(a,b){var e=this.maps[this.api];var d=new GGeoXml(a);if(b){GEvent.addListener(d,"load",function(){d.gotoDefaultViewport(e)})}e.addOverlay(d)},addTileLayer:function(i,b,a,h,e,j){var d=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),0,"copyleft");var f=new GCopyrightCollection(a);f.addCopyright(d);var g=[];g[0]=new GTileLayer(f,h,e);g[0].isPng=function(){return true};g[0].getOpacity=function(){return b};g[0].getTileUrl=function(m,l){url=i;url=url.replace(/\{Z\}/g,l);url=url.replace(/\{X\}/g,m.x);url=url.replace(/\{Y\}/g,m.y);return url};if(j){var k=new GMapType(g,new GMercatorProjection(19),a,{errorMessage:"More "+a+" tiles coming soon"});this.maps[this.api].addMapType(k)}else{k=new GTileLayerOverlay(g[0]);this.maps[this.api].addOverlay(k)}this.tileLayers.push([i,k,true]);return k},toggleTileLayer:function(b){for(var a=0;a<this.tileLayers.length;a++){if(this.tileLayers[a][0]==b){if(this.tileLayers[a][2]){this.maps[this.api].removeOverlay(this.tileLayers[a][1]);this.tileLayers[a][2]=false}else{this.maps[this.api].addOverlay(this.tileLayers[a][1]);this.tileLayers[a][2]=true}}}},getPixelRatio:function(){var f=this.maps[this.api];var b=G_NORMAL_MAP.getProjection();var g=f.getCenter();var e=f.getZoom();var d=b.fromLatLngToPixel(g,e);var a=b.fromPixelToLatLng(new GPoint(d.x+3,d.y+4),e);return 10000/a.distanceFrom(g)},mousePosition:function(a){var d=document.getElementById(a);if(d!==null){var b=this.maps[this.api];GEvent.addListener(b,"mousemove",function(e){var f=e.lat().toFixed(4)+" / "+e.lng().toFixed(4);d.innerHTML=f});d.innerHTML="0.0000 / 0.0000"}}},LatLonPoint:{toProprietary:function(){return new GLatLng(this.lat,this.lon)},fromProprietary:function(a){this.lat=a.lat();this.lon=a.lng()}},Marker:{toProprietary:function(){var f=this;var e,g,i,a;var j={};if(this.labelText){j.title=this.labelText}if(this.iconUrl){var h=new GIcon(G_DEFAULT_ICON,this.iconUrl);h.printImage=h.mozPrintImage=h.image;if(this.iconSize){h.iconSize=new GSize(this.iconSize[0],this.iconSize[1]);var d;if(this.iconAnchor){d=new GPoint(this.iconAnchor[0],this.iconAnchor[1])}else{d=new GPoint(this.iconSize[0]/2,this.iconSize[1]/2)}h.iconAnchor=d}if(typeof(this.iconShadowUrl)!="undefined"){h.shadow=this.iconShadowUrl;if(this.iconShadowSize){h.shadowSize=new GSize(this.iconShadowSize[0],this.iconShadowSize[1])}}else{h.shadow="";h.shadowSize=""}if(this.transparent){h.transparent=this.transparent}if(this.imageMap){h.imageMap=this.imageMap}j.icon=h}if(this.draggable){j.draggable=this.draggable}var b=new GMarker(this.location.toProprietary("google"),j);if(this.infoBubble){if(this.hover){g="mouseover"}else{g="click"}GEvent.addListener(b,g,function(){b.openInfoWindowHtml(f.infoBubble,{maxWidth:100})})}if(this.hoverIconUrl){GEvent.addListener(b,"mouseover",function(){b.setImage(f.hoverIconUrl)});GEvent.addListener(b,"mouseout",function(){b.setImage(f.iconUrl)})}if(this.infoDiv){if(this.hover){g="mouseover"}else{g="click"}GEvent.addListener(b,g,function(){document.getElementById(f.div).innerHTML=f.infoDiv})}return b},openBubble:function(){var a=this.proprietary_marker;a.openInfoWindowHtml(this.infoBubble)},closeBubble:function(){var a=this.proprietary_marker;a.closeInfoWindow()},hide:function(){this.proprietary_marker.hide()},show:function(){this.proprietary_marker.show()},update:function(){point=new mxn.LatLonPoint();point.fromProprietary("google",this.proprietary_marker.getPoint());this.location=point}},Polyline:{toProprietary:function(){var a=[];for(var b=0,d=this.points.length;b<d;b++){a.push(this.points[b].toProprietary("google"))}if(this.closed||a[0].equals(a[d-1])){return new GPolygon(a,this.color,this.width,this.opacity,this.fillColor||"#5462E3",this.opacity||"0.3")}else{return new GPolyline(a,this.color,this.width,this.opacity)}},show:function(){throw"Not implemented"},hide:function(){throw"Not implemented"}}});