@@ -39,6 +39,7 @@ var App = (function ($, publ) {
39
39
lat : 35.689524 ,
40
40
zoom : 13 ,
41
41
maxzoom : 19 ,
42
+ fitMaxzoom : 17 ,
42
43
geocoderAddress : "現地住所" ,
43
44
geocoderDistrict : "区名"
44
45
} ;
@@ -74,6 +75,9 @@ var App = (function ($, publ) {
74
75
if ( defaults . maxzoom == null ) {
75
76
defaults . maxzoom = quick_hack . maxzoom ;
76
77
}
78
+ if ( defaults . fitMaxzoom == null ) {
79
+ defaults . fitMaxzoom = quick_hack . fitMaxzoom ;
80
+ }
77
81
if ( defaults . geocoderAddress == null ) {
78
82
defaults . geocoderAddress = quick_hack . geocoderAddress ;
79
83
}
@@ -451,12 +455,18 @@ var App = (function ($, publ) {
451
455
ol . extent . extend ( extent , feature . getGeometry ( ) . getExtent ( ) ) ;
452
456
} ) ;
453
457
maps . forEach ( function ( m ) {
454
- m . getView ( ) . fit ( extent , m . getSize ( ) ) ;
458
+ m . getView ( ) . fit ( extent , {
459
+ size : getMapSize ( m ) ,
460
+ maxZoom : defaults . fitMaxzoom
461
+ } ) ;
455
462
} ) ;
456
463
}
457
464
else if ( bounds . getSource ( ) . getFeatures ( ) . length > 0 ) {
458
465
maps . forEach ( function ( m ) {
459
- m . getView ( ) . fit ( bounds . getSource ( ) . getExtent ( ) , m . getSize ( ) ) ;
466
+ m . getView ( ) . fit ( bounds . getSource ( ) . getExtent ( ) , {
467
+ size : getMapSize ( m ) ,
468
+ maxZoom : defaults . fitMaxzoom
469
+ } ) ;
460
470
} ) ;
461
471
}
462
472
else if ( geolocation ) {
@@ -966,6 +976,17 @@ var App = (function ($, publ) {
966
976
} ) ;
967
977
}
968
978
979
+ function getMapSize ( map ) {
980
+ var size = map . getSize ( ) ;
981
+ if ( size . length === 2 && size [ 0 ] <= 0 && size [ 1 ] <= 0 ) {
982
+ size = [
983
+ $ ( "div#" + map . getTarget ( ) . id ) . width ( ) ,
984
+ $ ( "div#" + map . getTarget ( ) . id ) . height ( ) ,
985
+ ]
986
+ }
987
+ return size ;
988
+ }
989
+
969
990
/**
970
991
* Return public objects
971
992
*/
0 commit comments