Skip to content

Commit

Permalink
feat(StreetViewPanorama): fix OverlayViewHelper
Browse files Browse the repository at this point in the history
When OverlayView is used on StreetViewPanorama it can happen that `mapCanvasProjection.fromLatLngToDivPixel` returns nothing. This change catches that case and moves the overlay off canvas.
  • Loading branch information
novascreen authored and Thomas Hermann committed Jun 1, 2017
1 parent 7bd8c76 commit ab513a5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/lib/utils/OverlayViewHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,30 @@ function ensureOfType(inst, type, factory) {
function getLayoutStylesByBounds(mapCanvasProjection, offset, bounds) {
const ne = mapCanvasProjection.fromLatLngToDivPixel(bounds.getNorthEast());
const sw = mapCanvasProjection.fromLatLngToDivPixel(bounds.getSouthWest());
return {
return ne && sw ? {
left: `${sw.x + offset.x}px`,
top: `${ne.y + offset.y}px`,
width: `${ne.x - sw.x - offset.x}px`,
height: `${sw.y - ne.y - offset.y}px`,
} : {
left: `-9999px`,
top: `-9999px`,
};
}

function getLayoutStylesByPosition(mapCanvasProjection, offset, position) {
const {
x,
y,
} = mapCanvasProjection.fromLatLngToDivPixel(position);
const point = mapCanvasProjection.fromLatLngToDivPixel(position);
console.log(point);
if (point) {
const { x, y } = point;
return {
left: `${x + offset.x}px`,
top: `${y + offset.y}px`,
};
}
return {
left: `${x + offset.x}px`,
top: `${y + offset.y}px`,
left: `-9999px`,
top: `-9999px`,
};
}

Expand Down

0 comments on commit ab513a5

Please sign in to comment.