mirror of
https://github.com/google-map-react/google-map-react.git
synced 2025-12-08 18:26:32 +00:00
log2 support for IE
This commit is contained in:
parent
29038b9ce7
commit
6578b00e33
@ -18,6 +18,7 @@ import isArraysEqualEps from './utils/array_helper';
|
||||
import isPlainObject from './utils/is_plain_object';
|
||||
import pick from './utils/pick';
|
||||
import raf from './utils/raf';
|
||||
import log2 from './utils/math/log2';
|
||||
|
||||
import assign from 'lodash/object/assign';
|
||||
import isNumber from 'lodash/lang/isNumber';
|
||||
@ -311,7 +312,7 @@ export default class GoogleMap extends Component {
|
||||
const tilesPerWidth = Math.ceil(this.geoService_.getWidth() / K_GOOGLE_TILE_SIZE) + 2;
|
||||
const tilesPerHeight = Math.ceil(this.geoService_.getHeight() / K_GOOGLE_TILE_SIZE) + 2;
|
||||
const maxTilesPerDim = Math.max(tilesPerWidth, tilesPerHeight);
|
||||
return Math.ceil(Math.log2(maxTilesPerDim));
|
||||
return Math.ceil(log2(maxTilesPerDim));
|
||||
}
|
||||
return DEFAULT_MIN_ZOOM;
|
||||
}
|
||||
@ -870,4 +871,3 @@ export default class GoogleMap extends Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ export default function googleMapLoader(bootstrapURLKeys) {
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (find(Object.keys(bootstrapURLKeys), 'callback')) {
|
||||
console.error('"callback" key in bootstrapURLKeys is not allowed, ' +
|
||||
console.error('"callback" key in bootstrapURLKeys is not allowed, ' + // eslint-disable-line
|
||||
'use onGoogleApiLoaded property instead');
|
||||
throw new Error('"callback" key in bootstrapURLKeys is not allowed, ' +
|
||||
'use onGoogleApiLoaded property instead');
|
||||
|
||||
6
src/utils/math/log2.js
Normal file
6
src/utils/math/log2.js
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
const log2 = Math.log2
|
||||
? Math.log2
|
||||
: (x) => Math.log(x) / Math.LN2;
|
||||
|
||||
export default log2;
|
||||
@ -1,4 +1,5 @@
|
||||
const GOOGLE_TILE_SIZE = 256;
|
||||
import log2 from './math/log2';
|
||||
|
||||
function latLng2World({lat, lng}) {
|
||||
const sin = Math.sin(lat * Math.PI / 180);
|
||||
@ -74,8 +75,8 @@ export default {
|
||||
return null;
|
||||
}
|
||||
|
||||
const zoomX = Math.log2(width / GOOGLE_TILE_SIZE / dx);
|
||||
const zoomY = Math.log2(height / GOOGLE_TILE_SIZE / dy);
|
||||
const zoomX = log2(width / GOOGLE_TILE_SIZE / dx);
|
||||
const zoomY = log2(height / GOOGLE_TILE_SIZE / dy);
|
||||
const zoom = Math.floor(EPS + Math.min(zoomX, zoomY));
|
||||
|
||||
// TODO find center just unproject middle world point
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user