Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
overlayView._mountContainerToPane = function _mountContainerToPane() {
const mapPaneName = this.get(`mapPaneName`);
invariant(
!!mapPaneName,
`OverlayView requires a mapPaneName/defaultMapPaneName in your props instead of %s`,
mapPaneName
);
this.getPanes()[mapPaneName].appendChild(this._containerElement);
};
overlayView._getPixelPosition = function _getPixelPosition() {
const projection = this.getProjection();
let position = this.get(`position`);
invariant(
!!position,
`OverlayView requires a position/defaultPosition in your props instead of %s`,
position
);
if (projection && position) {
if (!(position instanceof google.maps.LatLng)) {
position = new google.maps.LatLng(position.lat, position.lng);
}
return projection.fromLatLngToDivPixel(position);
}
};
export function triggerEvent(component, ...args) {
const instance = __getInstance(component);
invariant(instance,
`The react-google-maps component %s is not mounted, hence we can't find an
associated Google Maps JavaScript API v3 instance with it.`, component);
return google.maps.event.trigger(instance, ...args);
}
overlayView._getPixelBounds = function _getPixelBounds() {
const projection = this.getProjection();
let bounds = this.get(`bounds`);
invariant(!!bounds, `OverlayView requires a bounds in your props instead of %s`, bounds);
if (projection && bounds) {
if (!(bounds instanceof google.maps.LatLngBounds)) {
bounds = new google.maps.LatLngBounds(
new google.maps.LatLng(bounds.ne.lat, bounds.ne.lng),
new google.maps.LatLng(bounds.sw.lat, bounds.sw.lng)
);
}
return {
sw: projection.fromLatLngToDivPixel(this.bounds.getSouthWest()),
ne: projection.fromLatLngToDivPixel(this.bounds.getNorthEast()),
};
}
};