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.
- data/Gemfile +4 -0
- data/Gemfile.lock +14 -0
- data/LICENSE +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/lib/mapstraction/engine.rb +4 -0
- data/lib/mapstraction/version.rb +3 -0
- data/lib/mapstraction.rb +5 -0
- data/mapstraction/.gitignore +17 -0
- data/mapstraction.gemspec +17 -0
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/mxn-min.js +15 -0
- data/vendor/assets/javascripts/mxn.cartociudad.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.cartociudad.geocoder.js +46 -0
- data/vendor/assets/javascripts/mxn.cloudmade.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.cloudmade.core.js +383 -0
- data/vendor/assets/javascripts/mxn.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.core.js +1892 -0
- data/vendor/assets/javascripts/mxn.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.geocoder.js +74 -0
- data/vendor/assets/javascripts/mxn.geocommons.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.geocommons.core.js +343 -0
- data/vendor/assets/javascripts/mxn.google.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.google.core.js +536 -0
- data/vendor/assets/javascripts/mxn.google.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.google.geocoder.js +87 -0
- data/vendor/assets/javascripts/mxn.googleearth.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.googleearth.core.js +350 -0
- data/vendor/assets/javascripts/mxn.googlev3.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.googlev3.core.js +630 -0
- data/vendor/assets/javascripts/mxn.googlev3.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.googlev3.geocoder.js +101 -0
- data/vendor/assets/javascripts/mxn.js +581 -0
- data/vendor/assets/javascripts/mxn.leaflet.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.leaflet.core.js +398 -0
- data/vendor/assets/javascripts/mxn.mapquest.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.mapquest.geocoder.js +63 -0
- data/vendor/assets/javascripts/mxn.microsoft.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.microsoft.core.js +429 -0
- data/vendor/assets/javascripts/mxn.microsoft7.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.microsoft7.core.js +458 -0
- data/vendor/assets/javascripts/mxn.microsoft7.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.microsoft7.geocoder.js +66 -0
- data/vendor/assets/javascripts/mxn.multimap.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.multimap.core.js +473 -0
- data/vendor/assets/javascripts/mxn.openlayers.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.openlayers.core.js +630 -0
- data/vendor/assets/javascripts/mxn.openlayers.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.openlayers.geocoder.js +106 -0
- data/vendor/assets/javascripts/mxn.openmq.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.openmq.core.js +364 -0
- data/vendor/assets/javascripts/mxn.openspace.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.openspace.core.js +460 -0
- data/vendor/assets/javascripts/mxn.ovi.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.ovi.core.js +508 -0
- data/vendor/assets/javascripts/mxn.ovi.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.ovi.geocoder.js +129 -0
- data/vendor/assets/javascripts/mxn.yahoo.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.yahoo.core.js +406 -0
- data/vendor/assets/javascripts/mxn.yandex.core-min.js +15 -0
- data/vendor/assets/javascripts/mxn.yandex.core.js +527 -0
- data/vendor/assets/javascripts/mxn.yandex.geocoder-min.js +15 -0
- data/vendor/assets/javascripts/mxn.yandex.geocoder.js +66 -0
- metadata +110 -0
@@ -0,0 +1,406 @@
|
|
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('yahoo', {
|
16
|
+
|
17
|
+
Mapstraction: {
|
18
|
+
|
19
|
+
init: function(element,api) {
|
20
|
+
var me = this;
|
21
|
+
if (YMap) {
|
22
|
+
this.maps[api] = new YMap(element);
|
23
|
+
|
24
|
+
YEvent.Capture(this.maps[api], EventsList.MouseClick, function(event,location) {
|
25
|
+
me.clickHandler(location.Lat, location.Lon, location, me);
|
26
|
+
me.click.fire({'location': new mxn.LatLonPoint(location.Lat, location.Lon)});
|
27
|
+
});
|
28
|
+
YEvent.Capture(this.maps[api], EventsList.changeZoom, function() {
|
29
|
+
me.moveendHandler(me);
|
30
|
+
me.changeZoom.fire();
|
31
|
+
});
|
32
|
+
YEvent.Capture(this.maps[api], EventsList.endPan, function() {
|
33
|
+
me.moveendHandler(me);
|
34
|
+
me.endPan.fire();
|
35
|
+
});
|
36
|
+
YEvent.Capture(this.maps[api], EventsList.endAutoPan, function() {
|
37
|
+
me.endPan.fire();
|
38
|
+
});
|
39
|
+
|
40
|
+
this.loaded[api] = true;
|
41
|
+
me.load.fire();
|
42
|
+
}
|
43
|
+
else {
|
44
|
+
alert(api + ' map script not imported');
|
45
|
+
}
|
46
|
+
},
|
47
|
+
|
48
|
+
applyOptions: function(){
|
49
|
+
|
50
|
+
/*
|
51
|
+
if (this.options.enableDragging) {
|
52
|
+
map.enableDragMap();
|
53
|
+
} else {
|
54
|
+
map.disableDragMap();
|
55
|
+
}
|
56
|
+
*/
|
57
|
+
|
58
|
+
},
|
59
|
+
|
60
|
+
resizeTo: function(width, height){
|
61
|
+
this.maps[this.api].resizeTo(new YSize(width,height));
|
62
|
+
},
|
63
|
+
|
64
|
+
addControls: function( args ) {
|
65
|
+
var map = this.maps[this.api];
|
66
|
+
|
67
|
+
if (args.pan) {
|
68
|
+
map.addPanControl();
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
// Yahoo doesn't check the pan control is there before trying to remove it
|
72
|
+
// so throws an exception :(
|
73
|
+
map.addPanControl();
|
74
|
+
map.removePanControl();
|
75
|
+
}
|
76
|
+
|
77
|
+
if (args.zoom == 'large') {
|
78
|
+
map.addZoomLong();
|
79
|
+
}
|
80
|
+
else if ( args.zoom == 'small' ) {
|
81
|
+
map.addZoomShort();
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
map.removeZoomScale();
|
85
|
+
}
|
86
|
+
},
|
87
|
+
|
88
|
+
addSmallControls: function() {
|
89
|
+
var map = this.maps[this.api];
|
90
|
+
map.addPanControl();
|
91
|
+
map.addZoomShort();
|
92
|
+
this.addControlsArgs.pan = true;
|
93
|
+
this.addControlsArgs.zoom = 'small';
|
94
|
+
},
|
95
|
+
|
96
|
+
addLargeControls: function() {
|
97
|
+
var map = this.maps[this.api];
|
98
|
+
map.addPanControl();
|
99
|
+
map.addZoomLong();
|
100
|
+
this.addControlsArgs.pan = true; // keep the controls in case of swap
|
101
|
+
this.addControlsArgs.zoom = 'large';
|
102
|
+
},
|
103
|
+
|
104
|
+
addMapTypeControls: function() {
|
105
|
+
var map = this.maps[this.api];
|
106
|
+
map.addTypeControl();
|
107
|
+
},
|
108
|
+
|
109
|
+
dragging: function(on) {
|
110
|
+
var map = this.maps[this.api];
|
111
|
+
if (on) {
|
112
|
+
map.enableDragMap();
|
113
|
+
} else {
|
114
|
+
map.disableDragMap();
|
115
|
+
}
|
116
|
+
},
|
117
|
+
|
118
|
+
setCenterAndZoom: function(point, zoom) {
|
119
|
+
var map = this.maps[this.api];
|
120
|
+
var pt = point.toProprietary(this.api);
|
121
|
+
|
122
|
+
var yzoom = 18 - zoom; // maybe?
|
123
|
+
map.drawZoomAndCenter(pt,yzoom);
|
124
|
+
},
|
125
|
+
|
126
|
+
addMarker: function(marker, old) {
|
127
|
+
var map = this.maps[this.api];
|
128
|
+
var pin = marker.toProprietary(this.api);
|
129
|
+
map.addOverlay(pin);
|
130
|
+
YEvent.Capture(pin, EventsList.MouseClick, function() {
|
131
|
+
marker.click.fire();
|
132
|
+
});
|
133
|
+
YEvent.Capture(pin, EventsList.openSmartWindow, function() {
|
134
|
+
marker.openInfoBubble.fire();
|
135
|
+
});
|
136
|
+
YEvent.Capture(pin, EventsList.closeSmartWindow, function() {
|
137
|
+
marker.closeInfoBubble.fire();
|
138
|
+
});
|
139
|
+
return pin;
|
140
|
+
},
|
141
|
+
|
142
|
+
removeMarker: function(marker) {
|
143
|
+
var map = this.maps[this.api];
|
144
|
+
map.removeOverlay(marker.proprietary_marker);
|
145
|
+
},
|
146
|
+
|
147
|
+
declutterMarkers: function(opts) {
|
148
|
+
throw 'Not supported';
|
149
|
+
},
|
150
|
+
|
151
|
+
addPolyline: function(polyline, old) {
|
152
|
+
var map = this.maps[this.api];
|
153
|
+
var pl = polyline.toProprietary(this.api);
|
154
|
+
map.addOverlay(pl);
|
155
|
+
return pl;
|
156
|
+
},
|
157
|
+
|
158
|
+
removePolyline: function(polyline) {
|
159
|
+
var map = this.maps[this.api];
|
160
|
+
map.removeOverlay(polyline.proprietary_polyline);
|
161
|
+
},
|
162
|
+
|
163
|
+
getCenter: function() {
|
164
|
+
var map = this.maps[this.api];
|
165
|
+
var pt = map.getCenterLatLon();
|
166
|
+
var point = new mxn.LatLonPoint(pt.Lat, pt.Lon);
|
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
|
+
map.panToLatLon(pt);
|
174
|
+
},
|
175
|
+
|
176
|
+
setZoom: function(zoom) {
|
177
|
+
var map = this.maps[this.api];
|
178
|
+
var yzoom = 18 - zoom; // maybe?
|
179
|
+
map.setZoomLevel(yzoom);
|
180
|
+
},
|
181
|
+
|
182
|
+
getZoom: function() {
|
183
|
+
var map = this.maps[this.api];
|
184
|
+
return 18 - map.getZoomLevel();
|
185
|
+
},
|
186
|
+
|
187
|
+
getZoomLevelForBoundingBox: function( bbox ) {
|
188
|
+
throw 'Not implemented';
|
189
|
+
},
|
190
|
+
|
191
|
+
setMapType: function(type) {
|
192
|
+
var map = this.maps[this.api];
|
193
|
+
|
194
|
+
switch(type) {
|
195
|
+
case mxn.Mapstraction.ROAD:
|
196
|
+
map.setMapType(YAHOO_MAP_REG);
|
197
|
+
break;
|
198
|
+
case mxn.Mapstraction.SATELLITE:
|
199
|
+
map.setMapType(YAHOO_MAP_SAT);
|
200
|
+
break;
|
201
|
+
case mxn.Mapstraction.HYBRID:
|
202
|
+
map.setMapType(YAHOO_MAP_HYB);
|
203
|
+
break;
|
204
|
+
default:
|
205
|
+
map.setMapType(YAHOO_MAP_REG);
|
206
|
+
}
|
207
|
+
},
|
208
|
+
|
209
|
+
getMapType: function() {
|
210
|
+
var map = this.maps[this.api];
|
211
|
+
var type = map.getCurrentMapType();
|
212
|
+
switch(type) {
|
213
|
+
case YAHOO_MAP_REG:
|
214
|
+
return mxn.Mapstraction.ROAD;
|
215
|
+
case YAHOO_MAP_SAT:
|
216
|
+
return mxn.Mapstraction.SATELLITE;
|
217
|
+
case YAHOO_MAP_HYB:
|
218
|
+
return mxn.Mapstraction.HYBRID;
|
219
|
+
default:
|
220
|
+
return null;
|
221
|
+
}
|
222
|
+
},
|
223
|
+
|
224
|
+
getBounds: function () {
|
225
|
+
var map = this.maps[this.api];
|
226
|
+
var ybox = map.getBoundsLatLon();
|
227
|
+
return new mxn.BoundingBox(ybox.LatMin, ybox.LonMin, ybox.LatMax, ybox.LonMax);
|
228
|
+
},
|
229
|
+
|
230
|
+
setBounds: function(bounds){
|
231
|
+
var map = this.maps[this.api];
|
232
|
+
var sw = bounds.getSouthWest();
|
233
|
+
var ne = bounds.getNorthEast();
|
234
|
+
|
235
|
+
if(sw.lon > ne.lon) {
|
236
|
+
sw.lon -= 360;
|
237
|
+
}
|
238
|
+
var center = new YGeoPoint((sw.lat + ne.lat)/2, (ne.lon + sw.lon)/2);
|
239
|
+
|
240
|
+
var container = map.getContainerSize();
|
241
|
+
for(var zoom = 1 ; zoom <= 17 ; zoom++){
|
242
|
+
var sw_pix = mxn.util.convertLatLonXY_Yahoo(sw,zoom);
|
243
|
+
var ne_pix = mxn.util.convertLatLonXY_Yahoo(ne,zoom);
|
244
|
+
if(sw_pix.x > ne_pix.x) {
|
245
|
+
sw_pix.x -= (1 << (26 - zoom)); //earth circumference in pixel
|
246
|
+
}
|
247
|
+
if(Math.abs(ne_pix.x - sw_pix.x) <= container.width &&
|
248
|
+
Math.abs(ne_pix.y - sw_pix.y) <= container.height){
|
249
|
+
map.drawZoomAndCenter(center, zoom); //Call drawZoomAndCenter here: OK if called multiple times anyway
|
250
|
+
break;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
},
|
254
|
+
|
255
|
+
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
|
256
|
+
throw 'Not implemented';
|
257
|
+
},
|
258
|
+
|
259
|
+
setImagePosition: function(id) {
|
260
|
+
throw 'Not implemented';
|
261
|
+
},
|
262
|
+
|
263
|
+
addOverlay: function(url, autoCenterAndZoom) {
|
264
|
+
var map = this.maps[this.api];
|
265
|
+
map.addOverlay(new YGeoRSS(url));
|
266
|
+
},
|
267
|
+
|
268
|
+
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
|
269
|
+
throw 'Not implemented';
|
270
|
+
},
|
271
|
+
|
272
|
+
toggleTileLayer: function(tile_url) {
|
273
|
+
throw 'Not implemented';
|
274
|
+
},
|
275
|
+
|
276
|
+
getPixelRatio: function() {
|
277
|
+
throw 'Not implemented';
|
278
|
+
},
|
279
|
+
|
280
|
+
mousePosition: function(element) {
|
281
|
+
throw 'Not implemented';
|
282
|
+
}
|
283
|
+
|
284
|
+
},
|
285
|
+
|
286
|
+
LatLonPoint: {
|
287
|
+
|
288
|
+
toProprietary: function() {
|
289
|
+
return new YGeoPoint(this.lat,this.lon);
|
290
|
+
},
|
291
|
+
|
292
|
+
fromProprietary: function(yahooPoint) {
|
293
|
+
this.lat = yahooPoint.Lat;
|
294
|
+
this.lon = yahooPoint.Lon;
|
295
|
+
}
|
296
|
+
|
297
|
+
},
|
298
|
+
|
299
|
+
Marker: {
|
300
|
+
|
301
|
+
toProprietary: function() {
|
302
|
+
var ymarker, size;
|
303
|
+
var infoBubble, event_action, infoDiv, div;
|
304
|
+
|
305
|
+
if(this.iconSize) {
|
306
|
+
size = new YSize(this.iconSize[0], this.iconSize[1]);
|
307
|
+
}
|
308
|
+
if(this.iconUrl) {
|
309
|
+
if(this.iconSize){
|
310
|
+
ymarker = new YMarker(this.location.toProprietary('yahoo'), new YImage(this.iconUrl, size));
|
311
|
+
}
|
312
|
+
else {
|
313
|
+
ymarker = new YMarker(this.location.toProprietary('yahoo'), new YImage(this.iconUrl));
|
314
|
+
}
|
315
|
+
}
|
316
|
+
else {
|
317
|
+
if(this.iconSize) {
|
318
|
+
ymarker = new YMarker(this.location.toProprietary('yahoo'), null, size);
|
319
|
+
}
|
320
|
+
else {
|
321
|
+
ymarker = new YMarker(this.location.toProprietary('yahoo'));
|
322
|
+
}
|
323
|
+
}
|
324
|
+
|
325
|
+
if(this.labelText) {
|
326
|
+
ymarker.addLabel(this.labelText);
|
327
|
+
}
|
328
|
+
|
329
|
+
if(this.infoBubble) {
|
330
|
+
infoBubble = this.infoBubble;
|
331
|
+
if(this.hover) {
|
332
|
+
event_action = EventsList.MouseOver;
|
333
|
+
}
|
334
|
+
else {
|
335
|
+
event_action = EventsList.MouseClick;
|
336
|
+
}
|
337
|
+
YEvent.Capture(ymarker, event_action, function() {
|
338
|
+
ymarker.openSmartWindow(infoBubble);
|
339
|
+
});
|
340
|
+
|
341
|
+
}
|
342
|
+
|
343
|
+
if(this.infoDiv) {
|
344
|
+
infoDiv = this.infoDiv;
|
345
|
+
div = this.div;
|
346
|
+
if(this.hover) {
|
347
|
+
event_action = EventsList.MouseOver;
|
348
|
+
}
|
349
|
+
else {
|
350
|
+
event_action = EventsList.MouseClick;
|
351
|
+
}
|
352
|
+
YEvent.Capture(ymarker, event_action, function() {
|
353
|
+
document.getElementById(div).innerHTML = infoDiv;
|
354
|
+
});
|
355
|
+
}
|
356
|
+
|
357
|
+
return ymarker;
|
358
|
+
},
|
359
|
+
|
360
|
+
openBubble: function() {
|
361
|
+
var ypin = this.proprietary_marker;
|
362
|
+
ypin.openSmartWindow(this.infoBubble);
|
363
|
+
},
|
364
|
+
|
365
|
+
closeBubble: function() {
|
366
|
+
var ypin = this.proprietary_marker;
|
367
|
+
ypin.closeSmartWindow();
|
368
|
+
},
|
369
|
+
|
370
|
+
hide: function() {
|
371
|
+
this.proprietary_marker.hide();
|
372
|
+
},
|
373
|
+
|
374
|
+
show: function() {
|
375
|
+
this.proprietary_marker.unhide();
|
376
|
+
},
|
377
|
+
|
378
|
+
update: function() {
|
379
|
+
throw 'Not implemented';
|
380
|
+
}
|
381
|
+
|
382
|
+
},
|
383
|
+
|
384
|
+
Polyline: {
|
385
|
+
|
386
|
+
toProprietary: function() {
|
387
|
+
var ypolyline;
|
388
|
+
var ypoints = [];
|
389
|
+
for (var i = 0, length = this.points.length ; i< length; i++){
|
390
|
+
ypoints.push(this.points[i].toProprietary('yahoo'));
|
391
|
+
}
|
392
|
+
ypolyline = new YPolyline(ypoints,this.color,this.width,this.opacity);
|
393
|
+
return ypolyline;
|
394
|
+
},
|
395
|
+
|
396
|
+
show: function() {
|
397
|
+
throw 'Not implemented';
|
398
|
+
},
|
399
|
+
|
400
|
+
hide: function() {
|
401
|
+
throw 'Not implemented';
|
402
|
+
}
|
403
|
+
|
404
|
+
}
|
405
|
+
|
406
|
+
});
|
@@ -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("yandex",{Mapstraction:{init:function(b,c){var d=this;if(YMaps){var a=this.maps[c]=new YMaps.Map(b);YMaps.Events.observe(a,a.Events.Click,function(f,h){var e=h.getCoordPoint().getX();var g=h.getCoordPoint().getY();d.click.fire({location:new mxn.LatLonPoint(e,g)})});YMaps.Events.observe(a,a.Events.SmoothZoomEnd,function(e){d.changeZoom.fire()});this.loaded[c]=true;d.load.fire()}else{alert(c+" map script not imported")}},applyOptions:function(){var a=this.maps[this.api];if(this.options.enableScrollWheelZoom){a.enableScrollZoom(true)}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].redraw()},addControls:function(a){var b=this.maps[this.api];if(a.zoom=="large"){this.addLargeControls()}else{if(a.zoom=="small"){this.addSmallControls()}}if(a.pan){this.controls.unshift(new YMaps.ToolBar());this.addControlsArgs.pan=true;b.addControl(this.controls[0])}if(a.scale){this.controls.unshift(new YMaps.ScaleLine());this.addControlsArgs.scale=true;b.addControl(this.controls[0])}if(a.overview){if(typeof(a.overview)!="number"){a.overview=5}this.controls.unshift(new YMaps.MiniMap(a.overview));this.addControlsArgs.overview=true;b.addControl(this.controls[0])}if(a.map_type){this.addMapTypeControls()}},addSmallControls:function(){var a=this.maps[this.api];this.controls.unshift(new YMaps.SmallZoom());this.addControlsArgs.zoom="small";a.addControl(this.controls[0])},addLargeControls:function(){var a=this.maps[this.api];this.controls.unshift(new YMaps.SmallZoom());this.addControlsArgs.zoom="large";a.addControl(this.controls[0])},addMapTypeControls:function(){var a=this.maps[this.api];this.controls.unshift(new YMaps.TypeControl());this.addControlsArgs.map_type=true;a.addControl(this.controls[0])},setCenterAndZoom:function(a,b){var d=this.maps[this.api];var c=a.toProprietary(this.api);d.setCenter(c,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];b.removeOverlay(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.addOverlay(c);return c},removePolyline:function(a){var b=this.maps[this.api];b.removeOverlay(a.proprietary_polyline)},getCenter:function(){var c=this.maps[this.api];var b=c.getCenter();var a=new mxn.LatLonPoint(b.getLat(),b.getLng());return a},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.setZoom(a)},getZoom:function(){var b=this.maps[this.api];var a=b.getZoom();return a},getZoomLevelForBoundingBox:function(e){var d=this.maps[this.api];var c=e.getNorthEast().toProprietary(this.api);var a=e.getSouthWest().toProprietary(this.api);var b=new YMaps.GeoBounds(c,a).getMapZoom(d);return b},setMapType:function(a){var b=this.maps[this.api];switch(a){case mxn.Mapstraction.ROAD:b.setType(YMaps.MapType.MAP);break;case mxn.Mapstraction.SATELLITE:b.setType(YMaps.MapType.SATELLITE);break;case mxn.Mapstraction.HYBRID:b.setType(YMaps.MapType.HYBRID);break;default:b.setType(a||YMaps.MapType.MAP)}},getMapType:function(){var b=this.maps[this.api];var a=b.getType();switch(a){case YMaps.MapType.MAP:return mxn.Mapstraction.ROAD;case YMaps.MapType.SATELLITE:return mxn.Mapstraction.SATELLITE;case YMaps.MapType.HYBRID:return mxn.Mapstraction.HYBRID;default:return null}},getBounds:function(){var d=this.maps[this.api];var b=d.getBounds();var c=b.getLeftBottom();var a=b.getRightTop();return new mxn.BoundingBox(c.getLat(),c.getLng(),a.getLat(),a.getLng())},setBounds:function(d){var g=this.maps[this.api];var b=d.getSouthWest();var f=d.getNorthEast();var a=new YMaps.GeoPoint(b.lon,b.lat);var c=new YMaps.GeoPoint(f.lon,f.lat);var e=new YMaps.GeoBounds(a,c);g.setZoom(e.getMapZoom(g));g.setCenter(e.getCenter())},addImageOverlay:function(c,a,g,l,h,i,e,k){var b=this.maps[this.api];var f=this;var j=function(m){var n;this.onAddToMap=function(p,o){n=o;n.appendChild(m);this.onMapUpdate()};this.onRemoveFromMap=function(){if(n){n.removeChild(m)}};this.onMapUpdate=function(){f.setImagePosition(c)}};var d=new j(k.imgElm);b.addOverlay(d);this.setImageOpacity(c,g);this.setImagePosition(c)},setImagePosition:function(g,d){var f=this.maps[this.api];var c=new YMaps.GeoPoint(d.latLng.left,d.latLng.top);var b=new YMaps.GeoPoint(d.latLng.right,d.latLng.bottom);var e=f.converter.coordinatesToMapPixels(c);var a=f.converter.coordinatesToMapPixels(b);d.pixels.top=e.y;d.pixels.left=e.x;d.pixels.bottom=a.y;d.pixels.right=a.x},addOverlay:function(b,c){var d=this.maps[this.api];var a=new YMaps.KML(b);d.addOverlay(a);YMaps.Events.observe(a,a.Events.Fault,function(e,f){alert("KML upload faults. Error: "+f)})},addTileLayer:function(l,f,e,k,g,m){var b=this.maps[this.api];var a=new YMaps.TileDataSource(l,true,true);a.getTileUrl=function(n,o){return this._tileUrlTemplate.replace(/\{X\}/g,n.x).replace(/\{Y\}/g,n.y).replace(/\{Z\}/g,o)};var j=new YMaps.Layer(a);j._$element.css("opacity",f);if(m){var i=Math.round(Math.random()*Date.now()).toString();YMaps.Layers.add(i,j);var c=new YMaps.MapType([i],e,{textColor:"#706f60",minZoom:k,maxZoom:g});var h;for(var d in b.__controls){if(b.__controls[d] instanceof YMaps.TypeControl){h=b.__controls[d];break}}if(!h){h=new YMaps.TypeControl();b.addControl(h)}h.addType(c)}else{b.addLayer(j);b.addCopyright(e)}this.tileLayers.push([l,j,true]);return j},toggleTileLayer:function(c){var b=this.maps[this.api];for(var a=0;a<this.tileLayers.length;a++){if(this.tileLayers[a][0]==c){if(this.tileLayers[a][2]){this.maps[this.api].removeLayer(this.tileLayers[a][1]);this.tileLayers[a][2]=false}else{this.maps[this.api].addLayer(this.tileLayers[a][1]);this.tileLayers[a][2]=true}}}},getPixelRatio:function(){throw"Not implemented"},mousePosition:function(a){var c=document.getElementById(a);if(c!==null){var b=this.maps[this.api];YMaps.Events.observe(b,b.Events.MouseMove,function(e,g){var d=g.getGeoPoint();var f=d.getY().toFixed(4)+" / "+d.getX().toFixed(4);c.innerHTML=f});c.innerHTML="0.0000 / 0.0000"}}},LatLonPoint:{toProprietary:function(){return new YMaps.GeoPoint(this.lon,this.lat)},fromProprietary:function(a){this.lat=a.getLat();this.lon=a.getLng();return this}},Marker:{toProprietary:function(){var c={hideIcon:false,draggable:this.draggable};if(this.iconUrl){var e=new YMaps.Style();var d=e.iconStyle=new YMaps.IconStyle();d.href=this.iconUrl;if(this.iconSize){d.size=new YMaps.Point(this.iconSize[0],this.iconSize[1]);var b;if(this.iconAnchor){b=new YMaps.Point(this.iconAnchor[0],this.iconAnchor[1])}else{b=new YMaps.Point(0,0)}d.offset=b}if(this.iconShadowUrl){d.shadow=new YMaps.IconShadowStyle();d.shadow.href=this.iconShadowUrl;if(this.iconShadowSize){d.shadow.size=new YMaps.Point(this.iconShadowSize[0],this.iconShadowSize[1]);d.shadow.offset=new YMaps.Point(0,0)}}c.style=e}var a=new YMaps.Placemark(this.location.toProprietary("yandex"),c);if(this.hoverIconUrl){var f=this;YMaps.Events.observe(a,a.Events.MouseEnter,function(h,i){var g=a.getOptions();if(!f.iconUrl){f.iconUrl=a._icon._context._computedStyle.iconStyle.href;g.style=a._icon._context._computedStyle}g.style.iconStyle.href=f.hoverIconUrl;a.setOptions(g)});YMaps.Events.observe(a,a.Events.MouseLeave,function(h,i){var g=a.getOptions();g.style.iconStyle.href=f.iconUrl;a.setOptions(g)})}if(this.labelText){a.name=this.labelText}if(this.infoBubble){a.setBalloonContent(this.infoBubble)}YMaps.Events.observe(a,a.Events.DragEnd,function(h){var g=new mxn.LatLonPoint().fromProprietary("yandex",h.getGeoPoint());this.mapstraction_marker.location=g;this.mapstraction_marker.dragend.fire(g)});return a},openBubble:function(){this.proprietary_marker.openBalloon()},closeBubble:function(){this.proprietary_marker.closeBalloon()},hide:function(){this.proprietary_marker._$iconContainer.addClass("YMaps-display-none")},show:function(){this.proprietary_marker._$iconContainer.removeClass("YMaps-display-none")},update:function(){point=new mxn.LatLonPoint();point.fromProprietary("yandex",this.proprietary_marker.getGeoPoint());this.location=point}},Polyline:{toProprietary:function(){var d=[];for(var b=0,c=this.points.length;b<c;b++){d.push(this.points[b].toProprietary("yandex"))}var a={style:{lineStyle:{strokeColor:this.color.replace("#",""),strokeWidth:this.width}}};if(this.closed||d[0].equals(d[c-1])){a.style.polygonStyle=a.style.lineStyle;if(this.fillColor){a.style.polygonStyle.fill=true;var e=(Math.round((this.opacity||1)*255)).toString(16);a.style.polygonStyle.fillColor=this.fillColor.replace("#","")+e}return new YMaps.Polygon(d,a)}else{return new YMaps.Polyline(d,a)}},hide:function(){this.proprietary_polyline._container._$container.addClass("YMaps-display-none")},show:function(){this.proprietary_polyline._container._$container.removeClass("YMaps-display-none")}}});
|