Created
April 29, 2017 20:39
-
-
Save helloncanella/ee591fca78f667bac6f71acdc058f620 to your computer and use it in GitHub Desktop.
Converting geolocation to pixel in the aps api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| geolocationToPixel({ lat, lng }) { | |
| const bounds = this.map.getBounds() | |
| const geolocation = new google.maps.LatLng({ lat, lng }) | |
| , topRight = this.map.getProjection().fromLatLngToPoint(bounds.getNorthEast()) | |
| , bottomLeft = this.map.getProjection().fromLatLngToPoint(bounds.getSouthWest()) | |
| , scale = Math.pow(2, this.map.getZoom()) | |
| , worldPoint = this.map.getProjection().fromLatLngToPoint(geolocation) | |
| return new google.maps.Point((worldPoint.x - bottomLeft.x) * scale, (worldPoint.y - topRight.y) * scale) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment