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,460 @@
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', {
16
+
17
+ Mapstraction: {
18
+
19
+ init: function(element, api) {
20
+ var me = this;
21
+ // create the map with no controls and don't centre popup info window
22
+ this.maps[api] = new OpenSpace.Map(element,{
23
+ controls: [],
24
+ centreInfoWindow: false
25
+ });
26
+ // note that these three controls are always there and the fact that
27
+ // there are three resident controls is used in addControls()
28
+ // enable map drag with mouse and keyboard
29
+ this.maps[api].addControl(new OpenLayers.Control.Navigation());
30
+ this.maps[api].addControl(new OpenLayers.Control.KeyboardDefaults());
31
+ // include copyright statement
32
+ this.maps[api].addControl(new OpenSpace.Control.CopyrightCollection());
33
+
34
+ this.maps[api].events.register(
35
+ "click",
36
+ this.maps[api],
37
+ function(evt) {
38
+ var point = this.getLonLatFromViewPortPx( evt.xy );
39
+ // convert to LatLonPoint
40
+ var llPoint = new mxn.LatLonPoint();
41
+ llPoint.fromProprietary(this.api, point);
42
+ me.clickHandler( llPoint.lat, llPoint.lon );
43
+ return false;
44
+ }
45
+ );
46
+ this.loaded[api] = true;
47
+ },
48
+
49
+ applyOptions: function(){
50
+ var map = this.maps[this.api];
51
+
52
+ // TODO: Add provider code
53
+ },
54
+
55
+ resizeTo: function(width, height){
56
+ this.currentElement.style.width = width;
57
+ this.currentElement.style.height = height;
58
+ this.maps[this.api].updateSize();
59
+ },
60
+
61
+ addControls: function( args ) {
62
+ var map = this.maps[this.api];
63
+ // remove existing controls but leave the basic navigation, keyboard
64
+ // and copyright controls in place these were added in addAPI and not
65
+ // normally be removed
66
+ for (var i = map.controls.length; i>3; i--) {
67
+ map.controls[i-1].deactivate();
68
+ map.removeControl(map.controls[i-1]);
69
+ }
70
+ // pan and zoom controls not available separately
71
+ if ( args.zoom == 'large') {
72
+ map.addControl(new OpenSpace.Control.LargeMapControl());
73
+ }
74
+ else if ( args.zoom == 'small' || args.pan ) {
75
+ map.addControl(new OpenSpace.Control.SmallMapControl());
76
+ }
77
+ if ( args.overview ) {
78
+ // this should work but as of OpenSpace 0.7.2 generates an error
79
+ // unless done before setCenterAndZoom
80
+ var osOverviewControl = new OpenSpace.Control.OverviewMap();
81
+ map.addControl(osOverviewControl);
82
+ osOverviewControl.maximizeControl();
83
+ }
84
+ if ( args.map_type ) {
85
+ // this is all you get with openspace, a control to switch on or
86
+ // off the layers and markers
87
+ // probably not much use to anybody
88
+ map.addControl(new OpenLayers.Control.LayerSwitcher());
89
+ }
90
+ },
91
+
92
+ addSmallControls: function() {
93
+ var map = this.maps[this.api];
94
+ map.addControl(new OpenSpace.Control.SmallMapControl());
95
+ },
96
+
97
+ addLargeControls: function() {
98
+ var map = this.maps[this.api];
99
+ map.addControl(new OpenSpace.Control.LargeMapControl());
100
+ },
101
+
102
+ addMapTypeControls: function() {
103
+ var map = this.maps[this.api];
104
+
105
+ // TODO: Add provider code
106
+ },
107
+
108
+ setCenterAndZoom: function(point, zoom) {
109
+ var map = this.maps[this.api];
110
+ var pt = point.toProprietary(this.api);
111
+
112
+ var oszoom = zoom-6;
113
+ if (oszoom<0) {
114
+ oszoom = 0;
115
+ }
116
+ else if (oszoom>10) {
117
+ oszoom = 10;
118
+ }
119
+ map.setCenter(pt, oszoom);
120
+ },
121
+
122
+ addMarker: function(marker, old) {
123
+ var map = this.maps[this.api];
124
+ var pin = marker.toProprietary(this.api);
125
+
126
+ map.addOverlay(pin);
127
+
128
+ return pin;
129
+ },
130
+
131
+ removeMarker: function(marker) {
132
+ var map = this.maps[this.api];
133
+
134
+ // TODO: Add provider code
135
+ },
136
+
137
+ declutterMarkers: function(opts) {
138
+ var map = this.maps[this.api];
139
+
140
+ // TODO: Add provider code
141
+ },
142
+
143
+ addPolyline: function(polyline, old) {
144
+ var map = this.maps[this.api];
145
+ var pl = polyline.toProprietary(this.api);
146
+
147
+ // TODO: Add provider code
148
+
149
+ return pl;
150
+ },
151
+
152
+ removePolyline: function(polyline) {
153
+ var map = this.maps[this.api];
154
+
155
+ // TODO: Add provider code
156
+ },
157
+
158
+ getCenter: function() {
159
+ var point;
160
+ var map = this.maps[this.api];
161
+
162
+ var pt = map.getCenter(); // an OpenSpace.MapPoint,
163
+ // UK National Grid
164
+ point = new mxn.LatLonPoint();
165
+ point.fromOpenSpace(pt); // convert to LatLonPoint
166
+
167
+ return point;
168
+ },
169
+
170
+ setCenter: function(point, options) {
171
+ var map = this.maps[this.api];
172
+ var pt = point.toProprietary(this.api);
173
+ if(options && options.pan) {
174
+ map.setCenter(pt.toProprietary(this.api));
175
+ }
176
+ else {
177
+ map.setCenter(pt.toProprietary(this.api));
178
+ }
179
+ },
180
+
181
+ setZoom: function(zoom) {
182
+ var map = this.maps[this.api];
183
+
184
+ var oszoom = zoom-6;
185
+ if (oszoom<0) {
186
+ oszoom = 0;
187
+ }
188
+ else if (oszoom>10) {
189
+ oszoom = 10;
190
+ }
191
+ map.zoomTo(oszoom);
192
+
193
+ },
194
+
195
+ getZoom: function() {
196
+ var map = this.maps[this.api];
197
+ var zoom;
198
+
199
+ zoom = map.zoom + 6; // convert to equivalent google zoom
200
+
201
+ return zoom;
202
+ },
203
+
204
+ getZoomLevelForBoundingBox: function( bbox ) {
205
+ var map = this.maps[this.api];
206
+ // NE and SW points from the bounding box.
207
+ var ne = bbox.getNorthEast();
208
+ var sw = bbox.getSouthWest();
209
+ var zoom;
210
+
211
+ var obounds = new OpenSpace.MapBounds();
212
+ obounds.extend(new mxn.LatLonPoint(sw.lat,sw.lon).toProprietary(this.api));
213
+ obounds.extend(new mxn.LatLonPoint(ne.lat,ne.lon).toProprietary(this.api));
214
+ zoom = map.getZoomForExtent(obounds) + 6; // get it and adjust to equivalent google zoom
215
+
216
+ return zoom;
217
+ },
218
+
219
+ setMapType: function(type) {
220
+ var map = this.maps[this.api];
221
+ switch(type) {
222
+ case mxn.Mapstraction.ROAD:
223
+ // TODO: Add provider code
224
+ break;
225
+ case mxn.Mapstraction.SATELLITE:
226
+ // TODO: Add provider code
227
+ break;
228
+ case mxn.Mapstraction.HYBRID:
229
+ // TODO: Add provider code
230
+ break;
231
+ default:
232
+ // TODO: Add provider code
233
+ }
234
+ },
235
+
236
+ getMapType: function() {
237
+ var map = this.maps[this.api];
238
+
239
+ // TODO: Add provider code
240
+ //return mxn.Mapstraction.ROAD;
241
+ //return mxn.Mapstraction.SATELLITE;
242
+ //return mxn.Mapstraction.HYBRID;
243
+ },
244
+
245
+ getBounds: function () {
246
+ var map = this.maps[this.api];
247
+
248
+ // array of openspace coords
249
+ // left, bottom, right, top
250
+ var olbox = map.calculateBounds().toArray();
251
+ var ossw = new OpenSpace.MapPoint( olbox[0], olbox[1] );
252
+ var osne = new OpenSpace.MapPoint( olbox[2], olbox[3] );
253
+ // convert to LatLonPoints
254
+ var sw = new mxn.LatLonPoint();
255
+ sw.fromOpenSpace(ossw);
256
+ var ne = new mxn.LatLonPoint();
257
+ ne.fromOpenSpace(osne);
258
+ return new mxn.BoundingBox(sw.lat, sw.lon, ne.lat, ne.lon);
259
+ },
260
+
261
+ setBounds: function(bounds){
262
+ var map = this.maps[this.api];
263
+ var sw = bounds.getSouthWest();
264
+ var ne = bounds.getNorthEast();
265
+
266
+ var obounds = new OpenSpace.MapBounds();
267
+ obounds.extend(new mxn.LatLonPoint(sw.lat,sw.lon).toProprietary(this.api));
268
+ obounds.extend(new mxn.LatLonPoint(ne.lat,ne.lon).toProprietary(this.api));
269
+ map.zoomToExtent(obounds);
270
+ },
271
+
272
+ addImageOverlay: function(id, src, opacity, west, south, east,
273
+ north, oContext) {
274
+ var map = this.maps[this.api];
275
+
276
+ // TODO: Add provider code
277
+ },
278
+
279
+ setImagePosition: function(id, oContext) {
280
+ var map = this.maps[this.api];
281
+ var topLeftPoint; var bottomRightPoint;
282
+
283
+ // TODO: Add provider code
284
+
285
+ //oContext.pixels.top = ...;
286
+ //oContext.pixels.left = ...;
287
+ //oContext.pixels.bottom = ...;
288
+ //oContext.pixels.right = ...;
289
+ },
290
+
291
+ addOverlay: function(url, autoCenterAndZoom) {
292
+ var map = this.maps[this.api];
293
+
294
+ // TODO: Add provider code
295
+ },
296
+
297
+ addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
298
+ var map = this.maps[this.api];
299
+ // TODO: Add provider code
300
+ },
301
+
302
+ toggleTileLayer: function(tile_url) {
303
+ var map = this.maps[this.api];
304
+ // TODO: Add provider code
305
+ },
306
+
307
+ getPixelRatio: function() {
308
+ var map = this.maps[this.api];
309
+ // TODO: Add provider code
310
+ },
311
+
312
+ mousePosition: function(element) {
313
+ var map = this.maps[this.api];
314
+
315
+ try {
316
+ map.events.register('mousemove', map, function (e) {
317
+ var lonLat = map.getLonLatFromViewPortPx(e.xy);
318
+ var lon = lonLat.lon * (180.0 / 20037508.34);
319
+ var lat = lonLat.lat * (180.0 / 20037508.34);
320
+ lat = (180/Math.PI)*(2*Math.atan(Math.exp(lat*Math.PI/180))-(Math.PI/2));
321
+ var loc = numFormatFloat(lat,4) + ' / ' + numFormatFloat(lon,4);
322
+ // numFormatFloat(X,4) simply formats floating point 'X' to
323
+ // 4 dec places
324
+ locDisp.innerHTML = loc;
325
+ });
326
+ locDisp.innerHTML = '0.0000 / 0.0000';
327
+ } catch (x) {
328
+ alert("Error: " + x);
329
+ }
330
+
331
+ // TODO: Add provider code
332
+ }
333
+ },
334
+
335
+ LatLonPoint: {
336
+
337
+ toProprietary: function() {
338
+ var lonlat = new OpenLayers.LonLat(this.lon, this.lat);
339
+ // need to convert to UK national grid
340
+ var gridProjection = new OpenSpace.GridProjection();
341
+ return gridProjection.getMapPointFromLonLat(lonlat);
342
+ // on OpenSpace.MapPoint
343
+
344
+ },
345
+
346
+ fromProprietary: function(osPoint) {
347
+ var gridProjection = new OpenSpace.GridProjection();
348
+ var olpt = gridProjection.getLonLatFromMapPoint(osPoint);
349
+ // an OpenLayers.LonLat
350
+ this.lon = olpt.lon;
351
+ this.lat = olpt.lat;
352
+ }
353
+
354
+ },
355
+
356
+ Marker: {
357
+
358
+ toProprietary: function() {
359
+ var size, anchor, icon;
360
+ if(this.iconSize) {
361
+ size = new OpenLayers.Size(this.iconSize[0],
362
+ this.iconSize[1]);
363
+ }
364
+ else {
365
+ size = new OpenLayers.Size(20,25);
366
+ }
367
+
368
+ if(this.iconAnchor) {
369
+ anchor = new OpenLayers.Pixel(this.iconAnchor[0],
370
+ this.iconAnchor[1]);
371
+ }
372
+ else {
373
+ // FIXME: hard-coding the anchor point
374
+ anchor = new OpenLayers.Pixel(-(size.w/2), -size.h);
375
+ }
376
+
377
+ if(this.iconUrl) {
378
+ icon = new OpenSpace.Icon(this.iconUrl, size, anchor);
379
+ }
380
+ else { // leave at default OpenSpace icon
381
+ }
382
+
383
+ // This requires an OpenLayers specific hack, doesn't work when
384
+ // not including OpenLayers.js
385
+ OpenLayers.Marker.Label(this.location.toProprietary(this.api), icon,
386
+ this.labelText, {mouseOver:true,tooltipsFormat:true});
387
+
388
+ var marker = new OpenLayers.Marker(this.location.toProprietary(this.api), icon);
389
+
390
+ return marker;
391
+ },
392
+
393
+ openBubble: function() {
394
+ // TODO: Add provider code
395
+ },
396
+
397
+ hide: function() {
398
+ // TODO: Add provider code
399
+ },
400
+
401
+ show: function() {
402
+ // TODO: Add provider code
403
+ },
404
+
405
+ update: function() {
406
+ // TODO: Add provider code
407
+ }
408
+ },
409
+
410
+ Polyline: {
411
+
412
+ toProprietary: function() {
413
+ var ospolyline;
414
+ var ospoints = [];
415
+ for (var i = 0, length = this.points.length ; i< length; i++){
416
+ // convert each point to OpenSpace.MapPoint
417
+ var ospoint = this.points[i].toProprietary(this.api);
418
+ var olgpoint = new OpenLayers.Geometry.Point(ospoint.getEasting(),ospoint.getNorthing());
419
+ ospoints.push(olgpoint);
420
+ }
421
+ if (this.closed) {
422
+ ospolyline = new OpenLayers.Feature.Vector(
423
+ new OpenLayers.Geometry.LinearRing(ospoints),
424
+ null,
425
+ {
426
+ fillColor: this.color,
427
+ strokeColor: this.color,
428
+ strokeOpacity: this.opacity,
429
+ fillOpacity: this.opacity,
430
+ strokeWidth: this.width
431
+ }
432
+ );
433
+ }
434
+ else {
435
+ ospolyline = new OpenLayers.Feature.Vector(
436
+ new OpenLayers.Geometry.LineString(ospoints),
437
+ null,
438
+ {
439
+ fillColor: 0,
440
+ strokeColor: this.color,
441
+ strokeOpacity: this.opacity,
442
+ fillOpacity: 0,
443
+ strokeWidth: this.width
444
+ }
445
+ );
446
+ }
447
+ return ospolyline;
448
+ },
449
+
450
+ show: function() {
451
+ // TODO: Add provider code
452
+ },
453
+
454
+ hide: function() {
455
+ // TODO: Add provider code
456
+ }
457
+
458
+ }
459
+
460
+ });
@@ -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("ovi",{Mapstraction:{init:function(c,d){var e=this;var a;var f=false;var b={center:false,zoom:false,mapsize:false};if(ovi.mapsapi){a=new ovi.mapsapi.map.Display(c);a.addComponent(new ovi.mapsapi.map.component.InfoBubbles());a.addComponent(new ovi.mapsapi.map.component.Behavior());a.addListener("click",function(g){coords=a.pixelToGeo(g.targetX,g.targetY);e.click.fire({location:new mxn.LatLonPoint(coords.latitude,coords.longitude)})});a.addListener("mapviewchangestart",function(g){if(g.data&g.MAPVIEWCHANGE_CENTER){b.center=true}if(g.data&g.MAPVIEWCHANGE_ZOOM){b.zoom=true}if(g.data&g.MAPVIEWCHANGE_SIZE){b.mapsize=true}});a.addListener("mapviewchangeupdate",function(g){if(g.data&g.MAPVIEWCHANGE_CENTER){b.center=true}if(g.data&g.MAPVIEWCHANGE_ZOOM){b.zoom=true}if(g.data&g.MAPVIEWCHANGE_SIZE){b.mapsize=true}});a.addListener("mapviewchangeend",function(g){if(!f){if(b.center&&b.mapsize){f=true;b.mapsize=false;e.load.fire()}}else{if(b.center){b.center=false;e.moveendHandler(e);e.endPan.fire()}}if(b.zoom){b.zoom=false;e.changeZoom.fire()}});this.maps[d]=a;this.loaded[d]=true}else{alert(d+" map script not imported")}},applyOptions:function(){var b=this.maps[this.api];if(this.options.enableScrollWheelZoom){b.addComponent(new ovi.mapsapi.map.component.zoom.MouseWheel())}else{var a=b.getComponentById("zoom.MouseWheel");if(a){b.removeComponent(a)}}},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.pan){b.addComponent(new ovi.mapsapi.map.component.Behavior())}if(a.zoom=="large"||a.zoom=="small"){b.addComponent(new ovi.mapsapi.map.component.ZoomBar())}if(a.overview){b.addComponent(new ovi.mapsapi.map.component.Overview())}if(a.scale){b.addComponent(new ovi.mapsapi.map.component.ScaleBar())}if(a.map_type){b.addComponent(new ovi.mapsapi.map.component.TypeSelector())}},addSmallControls:function(){var a=this.maps[this.api];a.addComponent(new ovi.mapsapi.map.component.ZoomBar())},addLargeControls:function(){var a=this.maps[this.api];a.addComponent(new ovi.mapsapi.map.component.ZoomBar())},addMapTypeControls:function(){var a=this.maps[this.api];a.addComponent(new ovi.mapsapi.map.component.TypeSelector())},setCenterAndZoom:function(a,b){var d=this.maps[this.api];var c=a.toProprietary(this.api);d.setCenter(c);d.setZoomLevel(b)},addMarker:function(b,a){var c=this.maps[this.api];var d=b.toProprietary(this.api);c.objects.add(d);return d},removeMarker:function(a){var b=this.maps[this.api];b.objects.remove(a.proprietary_marker)},declutterMarkers:function(a){throw"Not supported"},addPolyline:function(b,a){var d=this.maps[this.api];var c=b.toProprietary(this.api);d.objects.add(c);return c},removePolyline:function(a){var b=this.maps[this.api];b.objects.remove(a.proprietary_polyline)},getCenter:function(){var a=this.maps[this.api];return new mxn.LatLonPoint(a.center.latitude,a.center.longitude)},setCenter:function(a,b){var d=this.maps[this.api];var c=a.toProprietary(this.api);d.setCentre(c)},setZoom:function(a){var b=this.maps[this.api];b.setZoomLevel(a)},getZoom:function(){var a=this.maps[this.api];return a.zoomLevel},getZoomLevelForBoundingBox:function(e){var d=this.maps[this.api];var a=e.getSouthWest().toProprietary(this.api);var c=e.getNorthEast().toProprietary(this.api);var b=new ovi.mapsapi.geo.BoundingBox(a,c);return d.getBestZoomLevel(b)},setMapType:function(a){var b=this.maps[this.api];switch(a){case mxn.Mapstraction.ROAD:b.set("baseMapType",b.NORMAL);break;case mxn.Mapstraction.PHYSICAL:b.set("baseMapType",b.TERRAIN);break;case mxn.Mapstraction.HYBRID:throw"Not implemented";case mxn.Mapstraction.SATELLITE:b.set("baseMapType",b.SATELLITE);break;default:b.set("baseMapType",b.NORMAL);break}},getMapType:function(){var b=this.maps[this.api];var a=b.baseMapType;switch(a){case b.NORMAL:return mxn.Mapstraction.ROAD;case b.TERRAIN:return mxn.Mapstraction.PHYSICAL;case b.SATELLITE:return mxn.Mapstraction.SATELLITE;default:return null}},getBounds:function(){var c=this.maps[this.api];var d=c.getViewBounds();var a=d.topLeft;var b=d.bottomRight;return new mxn.BoundingBox(b.latitude,a.longitude,a.latitude,b.longitude)},setBounds:function(e){var h=this.maps[this.api];var a=e.getSouthWest();var g=e.getNorthEast();var c=new mxn.LatLonPoint(g.lat,a.lon).toProprietary(this.api);var f=new mxn.LatLonPoint(a.lat,g.lon).toProprietary(this.api);var b=new ovi.mapsapi.geo.BoundingBox(c,f);var d=false;h.zoomTo(b,d)},addImageOverlay:function(h,g,b,a,e,d,f,c){throw"Not implemented"},setImagePosition:function(b,a){throw"Not implemented"},addOverlay:function(a,b){throw"Not implemented"},addTileLayer:function(f,a,c,d,e,b){throw"Not implemented"},toggleTileLayer:function(a){throw"Not implemented"},getPixelRatio:function(){throw"Not implemented"},mousePosition:function(a){var c=this.maps[this.api];var d=document.getElementById(a);var b;if(d!==null){c.addListener("mousemove",function(e){b=c.pixelToGeo(e.targetX,e.targetY);d.innerHTML=b.latitude.toFixed(4)+" / "+b.longitude.toFixed(4)});d.innerHTML="0.0000 / 0.0000"}}},LatLonPoint:{toProprietary:function(){return new ovi.mapsapi.geo.Coordinate(this.lat,this.lon)},fromProprietary:function(a){this.lat=a.latitude;this.lon=a.longitude}},Marker:{toProprietary:function(){var d=[];var b=this;if(this.iconAnchor){d.anchor=[this.iconAnchor[0],this.iconAnchor[1]]}if(this.iconUrl){d.icon=this.iconUrl}this.proprietary_infobubble=null;var a=new ovi.mapsapi.map.Marker(b.location.toProprietary("ovi"),d);if(this.infoBubble){var c="click";if(this.hover){c="mouseover"}a.addListener(c,function(){b.openBubble()})}if(this.draggable){a.enableDrag();a.addListener("dragstart",function(e){var f=b.map.getComponentById("InfoBubbles");if(f.bubbleExists(b.proprietary_infobubble)){b.closeBubble();a.set("restore_infobubble",true)}},false);a.addListener("dragend",function(e){var f=e.dataTransfer.getData("application/map-drag-object-offset");var h=b.map.pixelToGeo(e.displayX-f.x+a.anchor.x,e.displayY-f.y+a.anchor.y);var g=b.map.getBoundingBox();if(g.contains(h)){b.location.lat=h.latitude;b.location.lon=h.longitude}if(a.get("restore_infobubble")){a.set("restore_infobubble",false);b.openBubble()}},false)}return a},openBubble:function(){if(!this.map){throw"This marker must be added to a map in order to manage a Bubble"}this.proprietary_infobubble=this.map.getComponentById("InfoBubbles").addBubble(this.infoBubble,this.location.toProprietary("ovi"))},closeBubble:function(){if(!this.map){throw"This marker must be added to a map in order to manage a Bubble"}if(this.map.getComponentById("InfoBubbles").bubbleExists(this.proprietary_infobubble)){this.map.getComponentById("InfoBubbles").removeBubble(this.proprietary_infobubble)}this.proprietary_infobubble=null},hide:function(){this.proprietary_marker.set("visibility",false)},show:function(){this.proprietary_marker.set("visibility",true)},update:function(){throw"Not implemented"}},Polyline:{toProprietary:function(){var g=[];for(var b=0,f=this.points.length;b<f;b++){g.push(this.points[b].toProprietary("ovi"))}if(this.closed||g[0].equals(g[f-1])){var d=new mxn.util.Color();d.setHexColor(this.color||"#5462E3");var c="rgba("+d.red+","+d.green+","+d.blue+","+(this.opacity||1)+")";var e={visibility:true,fillColor:c,color:this.color||"#5462E3",stroke:"solid",width:this.width||1};this.proprietary_polyline=new ovi.mapsapi.map.Polygon(g,e)}else{var a={visibility:true,color:this.color||"#5462E3",stroke:"solid",width:this.width||1};this.proprietary_polyline=new ovi.mapsapi.map.Polyline(g,a)}return this.proprietary_polyline},show:function(){this.proprietary_polyline.set("visibility",true)},hide:function(){this.proprietary_polyline.set("visibility",false)}}});