MCPcopy Index your code
hub / github.com/google-map-react/google-map-react / fromContainerPixelToLatLng

Method fromContainerPixelToLatLng

src/lib/geo/index.js:76–89  ·  view source on GitHub ↗

Returns the LatLng for the given offset from the map top-left.

(ptXY)

Source from the content-addressed store, hash-verified

74
75 /** Returns the LatLng for the given offset from the map top-left. */
76 fromContainerPixelToLatLng(ptXY) {
77 if (this.mapCanvasProjection_) {
78 const latLng = this.mapCanvasProjection_.fromContainerPixelToLatLng(ptXY);
79 return { lat: latLng.lat(), lng: latLng.lng() };
80 }
81
82 const ptxy = { ...ptXY };
83 ptxy.x -= this.transform_.width / 2;
84 ptxy.y -= this.transform_.height / 2;
85 const ptRes = this.transform_.pointLocation(Point.convert(ptxy));
86
87 ptRes.lng -= 360 * Math.round(ptRes.lng / 360); // convert 2 google format
88 return ptRes;
89 }
90
91 getWidth() {
92 return this.transform_.width;

Callers 2

drawMethod · 0.80
GoogleMapClass · 0.80

Calls 1

pointLocationMethod · 0.80

Tested by

no test coverage detected