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,630 @@
|
|
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('googlev3', {
|
16
|
+
|
17
|
+
Mapstraction: {
|
18
|
+
|
19
|
+
init: function(element, api){
|
20
|
+
var me = this;
|
21
|
+
if ( google && google.maps ){
|
22
|
+
// by default add road map and no controls
|
23
|
+
var myOptions = {
|
24
|
+
disableDefaultUI: true,
|
25
|
+
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
26
|
+
mapTypeControl: false,
|
27
|
+
mapTypeControlOptions: null,
|
28
|
+
navigationControl: false,
|
29
|
+
navigationControlOptions: null,
|
30
|
+
scrollwheel: false
|
31
|
+
};
|
32
|
+
|
33
|
+
// Background color can only be set at construction
|
34
|
+
// To provide some control, adopt any explicit element style
|
35
|
+
var backgroundColor = null;
|
36
|
+
if ( element.currentStyle ) {
|
37
|
+
backgroundColor = element.currentStyle['background-color'];
|
38
|
+
}
|
39
|
+
else if ( window.getComputedStyle ) {
|
40
|
+
backgroundColor = document.defaultView.getComputedStyle(element, null).getPropertyValue('background-color');
|
41
|
+
}
|
42
|
+
// Only set the background if a style has been explicitly set, ruling out the "transparent" default
|
43
|
+
if ( backgroundColor && 'transparent' !== backgroundColor ) {
|
44
|
+
myOptions.backgroundColor = backgroundColor;
|
45
|
+
}
|
46
|
+
|
47
|
+
// find controls
|
48
|
+
if (!this.addControlsArgs && loadoptions.addControlsArgs) {
|
49
|
+
this.addControlsArgs = loadoptions.addControlsArgs;
|
50
|
+
}
|
51
|
+
if (this.addControlsArgs) {
|
52
|
+
if (this.addControlsArgs.zoom) {
|
53
|
+
myOptions.navigationControl = true;
|
54
|
+
if (this.addControlsArgs.zoom == 'small') {
|
55
|
+
myOptions.navigationControlOptions = {style: google.maps.NavigationControlStyle.SMALL};
|
56
|
+
}
|
57
|
+
if (this.addControlsArgs.zoom == 'large') {
|
58
|
+
myOptions.navigationControlOptions = {style: google.maps.NavigationControlStyle.ZOOM_PAN};
|
59
|
+
}
|
60
|
+
}
|
61
|
+
if (this.addControlsArgs.map_type) {
|
62
|
+
myOptions.mapTypeControl = true;
|
63
|
+
myOptions.mapTypeControlOptions = {style: google.maps.MapTypeControlStyle.DEFAULT};
|
64
|
+
}
|
65
|
+
if (this.addControlsArgs.overview) {
|
66
|
+
myOptions.overviewMapControl = true;
|
67
|
+
myOptions.overviewMapControlOptions = {opened: true};
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
var map = new google.maps.Map(element, myOptions);
|
72
|
+
|
73
|
+
var fireOnNextIdle = [];
|
74
|
+
|
75
|
+
google.maps.event.addListener(map, 'idle', function() {
|
76
|
+
var fireListCount = fireOnNextIdle.length;
|
77
|
+
if (fireListCount > 0) {
|
78
|
+
var fireList = fireOnNextIdle.splice(0, fireListCount);
|
79
|
+
var handler;
|
80
|
+
while((handler = fireList.shift())){
|
81
|
+
handler();
|
82
|
+
}
|
83
|
+
}
|
84
|
+
});
|
85
|
+
|
86
|
+
// deal with click
|
87
|
+
google.maps.event.addListener(map, 'click', function(location){
|
88
|
+
me.click.fire({'location':
|
89
|
+
new mxn.LatLonPoint(location.latLng.lat(),location.latLng.lng())
|
90
|
+
});
|
91
|
+
});
|
92
|
+
|
93
|
+
// deal with zoom change
|
94
|
+
google.maps.event.addListener(map, 'zoom_changed', function(){
|
95
|
+
// zoom_changed fires before the zooming has finished so we
|
96
|
+
// wait for the next idle event before firing our changezoom
|
97
|
+
// so that method calls report the correct values
|
98
|
+
fireOnNextIdle.push(function() {
|
99
|
+
me.changeZoom.fire();
|
100
|
+
});
|
101
|
+
});
|
102
|
+
|
103
|
+
// deal with map movement
|
104
|
+
google.maps.event.addListener(map, 'dragend', function(){
|
105
|
+
me.moveendHandler(me);
|
106
|
+
me.endPan.fire();
|
107
|
+
});
|
108
|
+
|
109
|
+
// deal with initial tile loading
|
110
|
+
var loadListener = google.maps.event.addListener(map, 'tilesloaded', function(){
|
111
|
+
me.load.fire();
|
112
|
+
google.maps.event.removeListener( loadListener );
|
113
|
+
});
|
114
|
+
|
115
|
+
this.maps[api] = map;
|
116
|
+
this.loaded[api] = true;
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
alert(api + ' map script not imported');
|
120
|
+
}
|
121
|
+
},
|
122
|
+
|
123
|
+
applyOptions: function(){
|
124
|
+
var map = this.maps[this.api];
|
125
|
+
var myOptions = [];
|
126
|
+
if (this.options.enableDragging) {
|
127
|
+
myOptions.draggable = true;
|
128
|
+
}
|
129
|
+
if (this.options.enableScrollWheelZoom){
|
130
|
+
myOptions.scrollwheel = true;
|
131
|
+
}
|
132
|
+
map.setOptions(myOptions);
|
133
|
+
},
|
134
|
+
|
135
|
+
resizeTo: function(width, height){
|
136
|
+
this.currentElement.style.width = width;
|
137
|
+
this.currentElement.style.height = height;
|
138
|
+
var map = this.maps[this.api];
|
139
|
+
google.maps.event.trigger(map,'resize');
|
140
|
+
},
|
141
|
+
|
142
|
+
addControls: function( args ) {
|
143
|
+
var map = this.maps[this.api];
|
144
|
+
var myOptions;
|
145
|
+
// remove old controls
|
146
|
+
|
147
|
+
// Google has a combined zoom and pan control.
|
148
|
+
if (args.zoom || args.pan) {
|
149
|
+
if (args.zoom == 'large'){
|
150
|
+
this.addLargeControls();
|
151
|
+
} else {
|
152
|
+
this.addSmallControls();
|
153
|
+
}
|
154
|
+
}
|
155
|
+
if (args.scale){
|
156
|
+
myOptions = {
|
157
|
+
scaleControl:true,
|
158
|
+
scaleControlOptions: {style:google.maps.ScaleControlStyle.DEFAULT}
|
159
|
+
};
|
160
|
+
map.setOptions(myOptions);
|
161
|
+
this.addControlsArgs.scale = true;
|
162
|
+
}
|
163
|
+
if (args.map_type){
|
164
|
+
this.addMapTypeControls();
|
165
|
+
}
|
166
|
+
if (args.overview) {
|
167
|
+
myOptions = {
|
168
|
+
overviewMapControl: true,
|
169
|
+
overviewMapControlOptions: {opened: true}
|
170
|
+
};
|
171
|
+
map.setOptions(myOptions);
|
172
|
+
this.addControlsArgs.overview = true;
|
173
|
+
}
|
174
|
+
},
|
175
|
+
|
176
|
+
addSmallControls: function() {
|
177
|
+
var map = this.maps[this.api];
|
178
|
+
var myOptions = {
|
179
|
+
navigationControl: true,
|
180
|
+
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}
|
181
|
+
};
|
182
|
+
map.setOptions(myOptions);
|
183
|
+
|
184
|
+
this.addControlsArgs.pan = false;
|
185
|
+
this.addControlsArgs.scale = false;
|
186
|
+
this.addControlsArgs.zoom = 'small';
|
187
|
+
},
|
188
|
+
|
189
|
+
addLargeControls: function() {
|
190
|
+
var map = this.maps[this.api];
|
191
|
+
var myOptions = {
|
192
|
+
navigationControl: true,
|
193
|
+
navigationControlOptions: {style:google.maps.NavigationControlStyle.DEFAULT}
|
194
|
+
};
|
195
|
+
map.setOptions(myOptions);
|
196
|
+
this.addControlsArgs.pan = true;
|
197
|
+
this.addControlsArgs.zoom = 'large';
|
198
|
+
},
|
199
|
+
|
200
|
+
addMapTypeControls: function() {
|
201
|
+
var map = this.maps[this.api];
|
202
|
+
var myOptions = {
|
203
|
+
mapTypeControl: true,
|
204
|
+
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DEFAULT}
|
205
|
+
};
|
206
|
+
map.setOptions(myOptions);
|
207
|
+
this.addControlsArgs.map_type = true;
|
208
|
+
},
|
209
|
+
|
210
|
+
setCenterAndZoom: function(point, zoom) {
|
211
|
+
var map = this.maps[this.api];
|
212
|
+
var pt = point.toProprietary(this.api);
|
213
|
+
map.setCenter(pt);
|
214
|
+
map.setZoom(zoom);
|
215
|
+
},
|
216
|
+
|
217
|
+
addMarker: function(marker, old) {
|
218
|
+
return marker.toProprietary(this.api);
|
219
|
+
},
|
220
|
+
|
221
|
+
removeMarker: function(marker) {
|
222
|
+
// doesn't really remove them, just hides them
|
223
|
+
marker.hide();
|
224
|
+
},
|
225
|
+
|
226
|
+
declutterMarkers: function(opts) {
|
227
|
+
var map = this.maps[this.api];
|
228
|
+
// TODO: Add provider code
|
229
|
+
},
|
230
|
+
|
231
|
+
addPolyline: function(polyline, old) {
|
232
|
+
var map = this.maps[this.api];
|
233
|
+
var propPolyline = polyline.toProprietary(this.api);
|
234
|
+
propPolyline.setMap(map);
|
235
|
+
return propPolyline;
|
236
|
+
},
|
237
|
+
|
238
|
+
removePolyline: function(polyline) {
|
239
|
+
var map = this.maps[this.api];
|
240
|
+
polyline.proprietary_polyline.setMap(null);
|
241
|
+
},
|
242
|
+
|
243
|
+
getCenter: function() {
|
244
|
+
var map = this.maps[this.api];
|
245
|
+
var pt = map.getCenter();
|
246
|
+
return new mxn.LatLonPoint(pt.lat(),pt.lng());
|
247
|
+
},
|
248
|
+
|
249
|
+
setCenter: function(point, options) {
|
250
|
+
var map = this.maps[this.api];
|
251
|
+
var pt = point.toProprietary(this.api);
|
252
|
+
if (options && options.pan) {
|
253
|
+
map.panTo(pt);
|
254
|
+
}
|
255
|
+
else {
|
256
|
+
map.setCenter(pt);
|
257
|
+
}
|
258
|
+
},
|
259
|
+
|
260
|
+
setZoom: function(zoom) {
|
261
|
+
var map = this.maps[this.api];
|
262
|
+
map.setZoom(zoom);
|
263
|
+
},
|
264
|
+
|
265
|
+
getZoom: function() {
|
266
|
+
var map = this.maps[this.api];
|
267
|
+
return map.getZoom();
|
268
|
+
},
|
269
|
+
|
270
|
+
getZoomLevelForBoundingBox: function( bbox ) {
|
271
|
+
var map = this.maps[this.api];
|
272
|
+
var sw = bbox.getSouthWest().toProprietary(this.api);
|
273
|
+
var ne = bbox.getNorthEast().toProprietary(this.api);
|
274
|
+
var gLatLngBounds = new google.maps.LatLngBounds(sw, ne);
|
275
|
+
map.fitBounds(gLatLngBounds);
|
276
|
+
return map.getZoom();
|
277
|
+
},
|
278
|
+
|
279
|
+
setMapType: function(type) {
|
280
|
+
var map = this.maps[this.api];
|
281
|
+
switch(type) {
|
282
|
+
case mxn.Mapstraction.ROAD:
|
283
|
+
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
|
284
|
+
break;
|
285
|
+
case mxn.Mapstraction.SATELLITE:
|
286
|
+
map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
|
287
|
+
break;
|
288
|
+
case mxn.Mapstraction.HYBRID:
|
289
|
+
map.setMapTypeId(google.maps.MapTypeId.HYBRID);
|
290
|
+
break;
|
291
|
+
case mxn.Mapstraction.PHYSICAL:
|
292
|
+
map.setMapTypeId(google.maps.MapTypeId.TERRAIN);
|
293
|
+
break;
|
294
|
+
default:
|
295
|
+
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
|
296
|
+
}
|
297
|
+
},
|
298
|
+
|
299
|
+
getMapType: function() {
|
300
|
+
var map = this.maps[this.api];
|
301
|
+
var type = map.getMapTypeId();
|
302
|
+
switch(type) {
|
303
|
+
case google.maps.MapTypeId.ROADMAP:
|
304
|
+
return mxn.Mapstraction.ROAD;
|
305
|
+
case google.maps.MapTypeId.SATELLITE:
|
306
|
+
return mxn.Mapstraction.SATELLITE;
|
307
|
+
case google.maps.MapTypeId.HYBRID:
|
308
|
+
return mxn.Mapstraction.HYBRID;
|
309
|
+
case google.maps.MapTypeId.TERRAIN:
|
310
|
+
return mxn.Mapstraction.PHYSICAL;
|
311
|
+
default:
|
312
|
+
return null;
|
313
|
+
}
|
314
|
+
},
|
315
|
+
|
316
|
+
getBounds: function () {
|
317
|
+
var map = this.maps[this.api];
|
318
|
+
var gLatLngBounds = map.getBounds();
|
319
|
+
if (!gLatLngBounds) {
|
320
|
+
throw 'Bounds not available, map must be initialized';
|
321
|
+
}
|
322
|
+
var sw = gLatLngBounds.getSouthWest();
|
323
|
+
var ne = gLatLngBounds.getNorthEast();
|
324
|
+
return new mxn.BoundingBox(sw.lat(), sw.lng(), ne.lat(), ne.lng());
|
325
|
+
},
|
326
|
+
|
327
|
+
setBounds: function(bounds){
|
328
|
+
var map = this.maps[this.api];
|
329
|
+
var sw = bounds.getSouthWest().toProprietary(this.api);
|
330
|
+
var ne = bounds.getNorthEast().toProprietary(this.api);
|
331
|
+
var gLatLngBounds = new google.maps.LatLngBounds(sw, ne);
|
332
|
+
map.fitBounds(gLatLngBounds);
|
333
|
+
},
|
334
|
+
|
335
|
+
addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
|
336
|
+
var map = this.maps[this.api];
|
337
|
+
|
338
|
+
var imageBounds = new google.maps.LatLngBounds(
|
339
|
+
new google.maps.LatLng(south,west),
|
340
|
+
new google.maps.LatLng(north,east));
|
341
|
+
|
342
|
+
var groundOverlay = new google.maps.GroundOverlay(src, imageBounds);
|
343
|
+
groundOverlay.setMap(map);
|
344
|
+
},
|
345
|
+
|
346
|
+
setImagePosition: function(id, oContext) {
|
347
|
+
// do nothing
|
348
|
+
},
|
349
|
+
|
350
|
+
addOverlay: function(url, autoCenterAndZoom) {
|
351
|
+
var map = this.maps[this.api];
|
352
|
+
|
353
|
+
var opt = {preserveViewport: (!autoCenterAndZoom)};
|
354
|
+
var layer = new google.maps.KmlLayer(url, opt);
|
355
|
+
layer.setMap(map);
|
356
|
+
},
|
357
|
+
|
358
|
+
addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom, map_type) {
|
359
|
+
var map = this.maps[this.api];
|
360
|
+
var tilelayers = [];
|
361
|
+
var z_index = this.tileLayers.length || 0;
|
362
|
+
tilelayers[0] = {
|
363
|
+
getTileUrl: function (coord, zoom) {
|
364
|
+
url = tile_url;
|
365
|
+
url = url.replace(/\{Z\}/g, zoom);
|
366
|
+
url = url.replace(/\{X\}/g, coord.x);
|
367
|
+
url = url.replace(/\{Y\}/g, coord.y);
|
368
|
+
return url;
|
369
|
+
},
|
370
|
+
tileSize: new google.maps.Size(256, 256),
|
371
|
+
isPng: true,
|
372
|
+
minZoom: min_zoom,
|
373
|
+
maxZoom: max_zoom,
|
374
|
+
opacity: opacity,
|
375
|
+
name: copyright_text
|
376
|
+
};
|
377
|
+
var tileLayerOverlay = new google.maps.ImageMapType(tilelayers[0]);
|
378
|
+
if (map_type) {
|
379
|
+
map.mapTypes.set('tile' + z_index, tileLayerOverlay);
|
380
|
+
var mapTypeIds = [
|
381
|
+
google.maps.MapTypeId.ROADMAP,
|
382
|
+
google.maps.MapTypeId.HYBRID,
|
383
|
+
google.maps.MapTypeId.SATELLITE,
|
384
|
+
google.maps.MapTypeId.TERRAIN
|
385
|
+
];
|
386
|
+
for (var f = 0; f < this.tileLayers.length; f++) {
|
387
|
+
mapTypeIds.push('tile' + f);
|
388
|
+
}
|
389
|
+
var optionsUpdate = {mapTypeControlOptions: {mapTypeIds: mapTypeIds}};
|
390
|
+
map.setOptions(optionsUpdate);
|
391
|
+
}
|
392
|
+
else {
|
393
|
+
map.overlayMapTypes.insertAt(z_index, tileLayerOverlay);
|
394
|
+
}
|
395
|
+
this.tileLayers.push( [tile_url, tileLayerOverlay, true, z_index] );
|
396
|
+
return tileLayerOverlay;
|
397
|
+
},
|
398
|
+
|
399
|
+
toggleTileLayer: function(tile_url) {
|
400
|
+
var map = this.maps[this.api];
|
401
|
+
for (var f = 0; f < this.tileLayers.length; f++) {
|
402
|
+
var tileLayer = this.tileLayers[f];
|
403
|
+
if (tileLayer[0] == tile_url) {
|
404
|
+
if (tileLayer[2]) {
|
405
|
+
map.overlayMapTypes.removeAt(tileLayer[3]);
|
406
|
+
tileLayer[2] = false;
|
407
|
+
}
|
408
|
+
else {
|
409
|
+
map.overlayMapTypes.insertAt(tileLayer[3], tileLayer[1]);
|
410
|
+
tileLayer[2] = true;
|
411
|
+
}
|
412
|
+
}
|
413
|
+
}
|
414
|
+
},
|
415
|
+
|
416
|
+
getPixelRatio: function() {
|
417
|
+
var map = this.maps[this.api];
|
418
|
+
|
419
|
+
// TODO: Add provider code
|
420
|
+
},
|
421
|
+
|
422
|
+
mousePosition: function(element) {
|
423
|
+
var map = this.maps[this.api];
|
424
|
+
var locDisp = document.getElementById(element);
|
425
|
+
if (locDisp !== null) {
|
426
|
+
google.maps.event.addListener(map, 'mousemove', function (point) {
|
427
|
+
var loc = point.latLng.lat().toFixed(4) + ' / ' + point.latLng.lng().toFixed(4);
|
428
|
+
locDisp.innerHTML = loc;
|
429
|
+
});
|
430
|
+
locDisp.innerHTML = '0.0000 / 0.0000';
|
431
|
+
}
|
432
|
+
}
|
433
|
+
},
|
434
|
+
|
435
|
+
LatLonPoint: {
|
436
|
+
|
437
|
+
toProprietary: function() {
|
438
|
+
return new google.maps.LatLng(this.lat, this.lon);
|
439
|
+
},
|
440
|
+
|
441
|
+
fromProprietary: function(googlePoint) {
|
442
|
+
this.lat = googlePoint.lat();
|
443
|
+
this.lon = googlePoint.lng();
|
444
|
+
}
|
445
|
+
|
446
|
+
},
|
447
|
+
|
448
|
+
Marker: {
|
449
|
+
|
450
|
+
toProprietary: function() {
|
451
|
+
var options = {};
|
452
|
+
|
453
|
+
// do we have an Anchor?
|
454
|
+
var ax = 0; // anchor x
|
455
|
+
var ay = 0; // anchor y
|
456
|
+
|
457
|
+
if (this.iconAnchor) {
|
458
|
+
ax = this.iconAnchor[0];
|
459
|
+
ay = this.iconAnchor[1];
|
460
|
+
}
|
461
|
+
var gAnchorPoint = new google.maps.Point(ax,ay);
|
462
|
+
|
463
|
+
if (this.iconUrl) {
|
464
|
+
options.icon = new google.maps.MarkerImage(
|
465
|
+
this.iconUrl,
|
466
|
+
new google.maps.Size(this.iconSize[0], this.iconSize[1]),
|
467
|
+
new google.maps.Point(0, 0),
|
468
|
+
gAnchorPoint
|
469
|
+
);
|
470
|
+
|
471
|
+
// do we have a Shadow?
|
472
|
+
if (this.iconShadowUrl) {
|
473
|
+
if (this.iconShadowSize) {
|
474
|
+
var x = this.iconShadowSize[0];
|
475
|
+
var y = this.iconShadowSize[1];
|
476
|
+
options.shadow = new google.maps.MarkerImage(
|
477
|
+
this.iconShadowUrl,
|
478
|
+
new google.maps.Size(x,y),
|
479
|
+
new google.maps.Point(0,0),
|
480
|
+
gAnchorPoint
|
481
|
+
);
|
482
|
+
}
|
483
|
+
else {
|
484
|
+
options.shadow = new google.maps.MarkerImage(this.iconShadowUrl);
|
485
|
+
}
|
486
|
+
}
|
487
|
+
}
|
488
|
+
if (this.draggable) {
|
489
|
+
options.draggable = this.draggable;
|
490
|
+
}
|
491
|
+
if (this.labelText) {
|
492
|
+
options.title = this.labelText;
|
493
|
+
}
|
494
|
+
if (this.imageMap) {
|
495
|
+
options.shape = {
|
496
|
+
coord: this.imageMap,
|
497
|
+
type: 'poly'
|
498
|
+
};
|
499
|
+
}
|
500
|
+
|
501
|
+
options.position = this.location.toProprietary(this.api);
|
502
|
+
options.map = this.map;
|
503
|
+
|
504
|
+
var marker = new google.maps.Marker(options);
|
505
|
+
|
506
|
+
if (this.infoBubble) {
|
507
|
+
var event_action = "click";
|
508
|
+
if (this.hover) {
|
509
|
+
event_action = "mouseover";
|
510
|
+
}
|
511
|
+
google.maps.event.addListener(marker, event_action, function() {
|
512
|
+
marker.mapstraction_marker.openBubble();
|
513
|
+
});
|
514
|
+
}
|
515
|
+
|
516
|
+
if (this.hoverIconUrl) {
|
517
|
+
var gSize = new google.maps.Size(this.iconSize[0], this.iconSize[1]);
|
518
|
+
var zerozero = new google.maps.Point(0,0);
|
519
|
+
var hIcon = new google.maps.MarkerImage(
|
520
|
+
this.hoverIconUrl,
|
521
|
+
gSize,
|
522
|
+
zerozero,
|
523
|
+
gAnchorPoint
|
524
|
+
);
|
525
|
+
var Icon = new google.maps.MarkerImage(
|
526
|
+
this.iconUrl,
|
527
|
+
gSize,
|
528
|
+
zerozero,
|
529
|
+
gAnchorPoint
|
530
|
+
);
|
531
|
+
google.maps.event.addListener(
|
532
|
+
marker,
|
533
|
+
"mouseover",
|
534
|
+
function(){
|
535
|
+
marker.setIcon(hIcon);
|
536
|
+
}
|
537
|
+
);
|
538
|
+
google.maps.event.addListener(
|
539
|
+
marker,
|
540
|
+
"mouseout",
|
541
|
+
function(){ marker.setIcon(Icon); }
|
542
|
+
);
|
543
|
+
}
|
544
|
+
|
545
|
+
google.maps.event.addListener(marker, 'click', function() {
|
546
|
+
marker.mapstraction_marker.click.fire();
|
547
|
+
});
|
548
|
+
|
549
|
+
return marker;
|
550
|
+
},
|
551
|
+
|
552
|
+
openBubble: function() {
|
553
|
+
var infowindow, marker = this;
|
554
|
+
if (!this.hasOwnProperty('proprietary_infowindow') || this.proprietary_infowindow === null) {
|
555
|
+
infowindow = new google.maps.InfoWindow({
|
556
|
+
content: this.infoBubble
|
557
|
+
});
|
558
|
+
google.maps.event.addListener(infowindow, 'closeclick', function(closedWindow) {
|
559
|
+
marker.closeBubble();
|
560
|
+
});
|
561
|
+
}
|
562
|
+
else {
|
563
|
+
infowindow = this.proprietary_infowindow;
|
564
|
+
}
|
565
|
+
this.openInfoBubble.fire( { 'marker': this } );
|
566
|
+
infowindow.open(this.map, this.proprietary_marker);
|
567
|
+
this.proprietary_infowindow = infowindow; // Save so we can close it later
|
568
|
+
},
|
569
|
+
|
570
|
+
closeBubble: function() {
|
571
|
+
if (this.hasOwnProperty('proprietary_infowindow') && this.proprietary_infowindow !== null) {
|
572
|
+
this.proprietary_infowindow.close();
|
573
|
+
this.proprietary_infowindow = null;
|
574
|
+
this.closeInfoBubble.fire( { 'marker': this } );
|
575
|
+
}
|
576
|
+
},
|
577
|
+
|
578
|
+
hide: function() {
|
579
|
+
this.proprietary_marker.setOptions( { visible: false } );
|
580
|
+
},
|
581
|
+
|
582
|
+
show: function() {
|
583
|
+
this.proprietary_marker.setOptions( { visible: true } );
|
584
|
+
},
|
585
|
+
|
586
|
+
update: function() {
|
587
|
+
var point = new mxn.LatLonPoint();
|
588
|
+
point.fromProprietary('googlev3', this.proprietary_marker.getPosition());
|
589
|
+
this.location = point;
|
590
|
+
}
|
591
|
+
|
592
|
+
},
|
593
|
+
|
594
|
+
Polyline: {
|
595
|
+
|
596
|
+
toProprietary: function() {
|
597
|
+
var points = [];
|
598
|
+
for (var i = 0, length = this.points.length; i < length; i++) {
|
599
|
+
points.push(this.points[i].toProprietary('googlev3'));
|
600
|
+
}
|
601
|
+
|
602
|
+
var polyOptions = {
|
603
|
+
path: points,
|
604
|
+
strokeColor: this.color || '#000000',
|
605
|
+
strokeOpacity: this.opacity || 1.0,
|
606
|
+
strokeWeight: this.width || 3
|
607
|
+
};
|
608
|
+
|
609
|
+
if (this.closed) {
|
610
|
+
polyOptions.fillColor = this.fillColor || '#000000';
|
611
|
+
polyOptions.fillOpacity = polyOptions.strokeOpacity;
|
612
|
+
|
613
|
+
return new google.maps.Polygon(polyOptions);
|
614
|
+
}
|
615
|
+
else {
|
616
|
+
return new google.maps.Polyline(polyOptions);
|
617
|
+
}
|
618
|
+
},
|
619
|
+
|
620
|
+
show: function() {
|
621
|
+
throw 'Not implemented';
|
622
|
+
},
|
623
|
+
|
624
|
+
hide: function() {
|
625
|
+
throw 'Not implemented';
|
626
|
+
}
|
627
|
+
|
628
|
+
}
|
629
|
+
|
630
|
+
});
|
@@ -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("googlev3",{Geocoder:{init:function(){this.geocoders[this.api]=new google.maps.Geocoder()},geocode:function(b){var a=this;var c={};if(typeof(b)=="object"){if(b.hasOwnProperty("lat")&&b.hasOwnProperty("lon")){c.latLng=b.toProprietary(this.api)}else{c.address=[b.street,b.locality,b.region,b.country].join(", ")}}else{c.address=b}this.geocoders[this.api].geocode(c,function(e,d){a.geocode_callback(e,d)})},geocode_callback:function(f,e){var k={};if(e!=google.maps.GeocoderStatus.OK){this.error_callback(e)}else{k.street="";k.locality="";k.postcode="";k.region="";k.country="";var c=f[0];var h=[];for(var g=0;g<c.address_components.length;g++){var b=c.address_components[g];for(var d=0;d<b.types.length;d++){var a=b.types[d];switch(a){case"country":k.country=b.long_name;break;case"administrative_area_level_1":k.region=b.long_name;break;case"locality":k.locality=b.long_name;break;case"street_address":k.street=b.long_name;break;case"postal_code":k.postcode=b.long_name;break;case"street_number":h.unshift(b.long_name);break;case"route":h.push(b.long_name);break}}}if(k.street===""&&h.length>0){k.street=h.join(" ")}k.point=new mxn.LatLonPoint(c.geometry.location.lat(),c.geometry.location.lng());this.callback(k)}}}});
|