@@ -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
}
@@ -441,12 +445,18 @@ var App = (function ($, publ) {
441
445
ol . extent . extend ( extent , feature . getGeometry ( ) . getExtent ( ) ) ;
442
446
} ) ;
443
447
maps . forEach ( function ( m ) {
444
- m . getView ( ) . fit ( extent , m . getSize ( ) ) ;
448
+ m . getView ( ) . fit ( extent , {
449
+ size : getMapSize ( m ) ,
450
+ maxZoom : defaults . fitMaxzoom
451
+ } ) ;
445
452
} ) ;
446
453
}
447
454
else if ( bounds . getSource ( ) . getFeatures ( ) . length > 0 ) {
448
455
maps . forEach ( function ( m ) {
449
- m . getView ( ) . fit ( bounds . getSource ( ) . getExtent ( ) , m . getSize ( ) ) ;
456
+ m . getView ( ) . fit ( bounds . getSource ( ) . getExtent ( ) , {
457
+ size : getMapSize ( m ) ,
458
+ maxZoom : defaults . fitMaxzoom
459
+ } ) ;
450
460
} ) ;
451
461
}
452
462
else if ( geolocation ) {
@@ -919,6 +929,17 @@ var App = (function ($, publ) {
919
929
} ) ;
920
930
}
921
931
932
+ function getMapSize ( map ) {
933
+ var size = map . getSize ( ) ;
934
+ if ( size . length === 2 && size [ 0 ] <= 0 && size [ 1 ] <= 0 ) {
935
+ size = [
936
+ $ ( "div#" + map . getTarget ( ) . id ) . width ( ) ,
937
+ $ ( "div#" + map . getTarget ( ) . id ) . height ( ) ,
938
+ ]
939
+ }
940
+ return size ;
941
+ }
942
+
922
943
/**
923
944
* Return public objects
924
945
*/
0 commit comments