Projection
Stay organized with collections
Save and categorize content based on your preferences.
A projection is used to translate between on screen location and geographic coordinates on
the surface of the Earth (LatLng
). Screen
location is in screen pixels (not display pixels) with respect to the top left corner of the
map (and not necessarily of the whole screen).
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
Public Methods
public LatLng
fromScreenLocation (Point
point)
Returns the geographic location that corresponds to a screen location. The screen
location is specified in screen pixels (not display pixels) relative to the top left of
the map (not the top left of the whole screen).
Parameters
point |
A Point on
the screen in screen pixels. Must not be null . |
Returns
- The
LatLng
corresponding to the point
on the screen, or null
if the
ray through the given screen point does not intersect the ground plane (this might be
the case if the map is heavily tilted).
public VisibleRegion
getVisibleRegion ()
Gets a projection of the viewing frustum for converting between screen coordinates
and geo-latitude/longitude coordinates.
Returns
- The projection of the viewing frustum in its current state.
public Point
toScreenLocation (LatLng
location)
Returns a screen location that corresponds to a geographical coordinate
(LatLng
).
The screen location is in screen pixels (not display pixels) relative to the top left
of the map (not of the whole screen).
Parameters
location |
A LatLng
on the map to convert to a screen location. Must not be null . |
Returns
- A
Point
representing the screen location in screen pixels.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eProjection\u003c/code\u003e translates between screen locations (in pixels) and geographic coordinates (\u003ccode\u003eLatLng\u003c/code\u003e) on a map.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to convert screen points to \u003ccode\u003eLatLng\u003c/code\u003e and vice versa.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eProjection\u003c/code\u003e allows access to the visible region of the map, useful for determining the geographic bounds currently displayed.\u003c/p\u003e\n"],["\u003cp\u003eScreen coordinates are relative to the top-left corner of the map, not necessarily the entire screen.\u003c/p\u003e\n"]]],["The `Projection` class translates between screen locations and geographic coordinates. It offers three key methods: `fromScreenLocation` converts a screen `Point` to a `LatLng` geographic location. `getVisibleRegion` provides the viewing frustum for coordinate conversion. `toScreenLocation` converts a `LatLng` geographic coordinate to a screen `Point`. These methods use screen pixels relative to the map's top left, not the entire screen. In addition there are the inherited methods that come with the `Object` class.\n"],null,["# Projection\n\npublic final class **Projection** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nA projection is used to translate between on screen location and geographic coordinates on\nthe surface of the Earth ([LatLng](/android/reference/com/google/android/gms/maps/model/LatLng)). Screen\nlocation is in screen pixels (not display pixels) with respect to the top left corner of the\nmap (and not necessarily of the whole screen). \n\n### Public Method Summary\n\n|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [LatLng](/android/reference/com/google/android/gms/maps/model/LatLng) | [fromScreenLocation](/android/reference/com/google/android/gms/maps/Projection#fromScreenLocation(android.graphics.Point))([Point](//developer.android.com/reference/android/graphics/Point.html) point) Returns the geographic location that corresponds to a screen location. |\n| [VisibleRegion](/android/reference/com/google/android/gms/maps/model/VisibleRegion) | [getVisibleRegion](/android/reference/com/google/android/gms/maps/Projection#getVisibleRegion())() Gets a projection of the viewing frustum for converting between screen coordinates and geo-latitude/longitude coordinates. |\n| [Point](//developer.android.com/reference/android/graphics/Point.html) | [toScreenLocation](/android/reference/com/google/android/gms/maps/Projection#toScreenLocation(com.google.android.gms.maps.model.LatLng))([LatLng](/android/reference/com/google/android/gms/maps/model/LatLng) location) Returns a screen location that corresponds to a geographical coordinate ([LatLng](/android/reference/com/google/android/gms/maps/model/LatLng)). |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public [LatLng](/android/reference/com/google/android/gms/maps/model/LatLng)\n**fromScreenLocation** ([Point](//developer.android.com/reference/android/graphics/Point.html) point)\n\nReturns the geographic location that corresponds to a screen location. The screen\nlocation is specified in screen pixels (not display pixels) relative to the top left of\nthe map (not the top left of the whole screen). \n\n##### Parameters\n\n| point | A [Point](//developer.android.com/reference/android/graphics/Point.html) on the screen in screen pixels. Must not be `null`. |\n|-------|------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- The [LatLng](/android/reference/com/google/android/gms/maps/model/LatLng) corresponding to the `point` on the screen, or `null` if the ray through the given screen point does not intersect the ground plane (this might be the case if the map is heavily tilted). \n\n#### public [VisibleRegion](/android/reference/com/google/android/gms/maps/model/VisibleRegion)\n**getVisibleRegion** ()\n\nGets a projection of the viewing frustum for converting between screen coordinates\nand geo-latitude/longitude coordinates. \n\n##### Returns\n\n- The projection of the viewing frustum in its current state. \n\n#### public [Point](//developer.android.com/reference/android/graphics/Point.html)\n**toScreenLocation** ([LatLng](/android/reference/com/google/android/gms/maps/model/LatLng) location)\n\nReturns a screen location that corresponds to a geographical coordinate\n([LatLng](/android/reference/com/google/android/gms/maps/model/LatLng)).\nThe screen location is in screen pixels (not display pixels) relative to the top left\nof the map (not of the whole screen). \n\n##### Parameters\n\n| location | A [LatLng](/android/reference/com/google/android/gms/maps/model/LatLng) on the map to convert to a screen location. Must not be `null`. |\n|----------|-----------------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- A [Point](//developer.android.com/reference/android/graphics/Point.html) representing the screen location in screen pixels."]]