Skip to content

Commit fd06b3b

Browse files
committed
Applied fix for googlev3 controls not showing from mapstraction/mxn#257
1 parent ab94810 commit fd06b3b

1 file changed

Lines changed: 35 additions & 30 deletions

File tree

app/assets/javascripts/mxn.googlev3.core.js

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
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-
*/
151
mxn.register('googlev3', {
162

173
Mapstraction: {
@@ -25,9 +11,10 @@ Mapstraction: {
2511
mapTypeId: google.maps.MapTypeId.ROADMAP,
2612
mapTypeControl: false,
2713
mapTypeControlOptions: null,
28-
navigationControl: false,
29-
navigationControlOptions: null,
30-
scrollwheel: false
14+
zoomControl: false,
15+
zoomControlOptions: null,
16+
scrollwheel: false,
17+
disableDoubleClickZoom: true
3118
};
3219

3320
// Background color can only be set at construction
@@ -50,12 +37,13 @@ Mapstraction: {
5037
}
5138
if (this.addControlsArgs) {
5239
if (this.addControlsArgs.zoom) {
53-
myOptions.navigationControl = true;
40+
myOptions.zoomControl = true;
5441
if (this.addControlsArgs.zoom == 'small') {
55-
myOptions.navigationControlOptions = {style: google.maps.NavigationControlStyle.SMALL};
42+
myOptions.zoomControlOptions = {style: google.maps.ZoomControlStyle.SMALL};
5643
}
5744
if (this.addControlsArgs.zoom == 'large') {
58-
myOptions.navigationControlOptions = {style: google.maps.NavigationControlStyle.ZOOM_PAN};
45+
myOptions.zoomControlOptions = {style: google.maps.ZoomControlStyle.LARGE};
46+
myOptions.panControl = true;
5947
}
6048
}
6149
if (this.addControlsArgs.map_type) {
@@ -126,9 +114,21 @@ Mapstraction: {
126114
if (this.options.enableDragging) {
127115
myOptions.draggable = true;
128116
}
117+
else{
118+
myOptions.draggable = false;
119+
}
129120
if (this.options.enableScrollWheelZoom){
130121
myOptions.scrollwheel = true;
131122
}
123+
else{
124+
myOptions.scrollwheel = false;
125+
}
126+
if(this.options.disableDoubleClickZoom){
127+
myOptions.disableDoubleClickZoom = true;
128+
}
129+
else{
130+
myOptions.disableDoubleClickZoom = false;
131+
}
132132
map.setOptions(myOptions);
133133
},
134134

@@ -144,13 +144,17 @@ Mapstraction: {
144144
var myOptions;
145145
// remove old controls
146146

147-
// Google has a combined zoom and pan control.
148-
if (args.zoom || args.pan) {
147+
if (args.pan) {
148+
map.setOptions({ panControl: true });
149+
}
150+
if (args.zoom) {
151+
myOptions = { zoomControl: true };
149152
if (args.zoom == 'large'){
150-
this.addLargeControls();
153+
myOptions.zoomControlOptions = {style: google.maps.ZoomControlStyle.LARGE};
151154
} else {
152-
this.addSmallControls();
155+
myOptions.zoomControlOptions = {style: google.maps.ZoomControlStyle.SMALL};
153156
}
157+
map.setOptions(myOptions);
154158
}
155159
if (args.scale){
156160
myOptions = {
@@ -176,8 +180,8 @@ Mapstraction: {
176180
addSmallControls: function() {
177181
var map = this.maps[this.api];
178182
var myOptions = {
179-
navigationControl: true,
180-
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}
183+
zoomControl: true,
184+
zoomControlOptions: {style: google.maps.ZoomControlStyle.SMALL}
181185
};
182186
map.setOptions(myOptions);
183187

@@ -189,8 +193,9 @@ Mapstraction: {
189193
addLargeControls: function() {
190194
var map = this.maps[this.api];
191195
var myOptions = {
192-
navigationControl: true,
193-
navigationControlOptions: {style:google.maps.NavigationControlStyle.DEFAULT}
196+
zoomControl: true,
197+
zoomControlOptions: {style:google.maps.ZoomControlStyle.LARGE},
198+
panControl: true
194199
};
195200
map.setOptions(myOptions);
196201
this.addControlsArgs.pan = true;
@@ -618,11 +623,11 @@ Polyline: {
618623
},
619624

620625
show: function() {
621-
throw 'Not implemented';
626+
this.proprietary_polyline.setVisible(true);
622627
},
623628

624629
hide: function() {
625-
throw 'Not implemented';
630+
this.proprietary_polyline.setVisible(false);
626631
}
627632

628633
}

0 commit comments

Comments
 (0)