UrlTileProvider
Stay organized with collections
Save and categorize content based on your preferences.
A partial implementation of TileProvider
that only requires a URL that points to an image to be provided.
Note that this class requires that all the images have the same dimensions.
Public Constructor Summary
Public Method Summary
final Tile
|
getTile
(int x, int y, int zoom) Returns the Tile
to be used for this tile coordinate.
|
abstract URL
|
getTileUrl
(int x, int y, int zoom) Returns a URL
that
points to the image to be used for this tile.
|
Inherited Method Summary
From class java.lang.Object
Public Constructors
public
UrlTileProvider
(int width, int
height)
Constructs a UrlTileProvider.
Parameters
Public Methods
public final Tile
getTile
(int x, int y,
int zoom)
public abstract URL
getTileUrl
(int x, int y, int
zoom)
Returns a URL
that points to the
image to be used for this tile. If no image is found on the initial request, further
requests will be made with an exponential backoff. If you do not wish to provide an
image for this tile coordinate, return null.
Parameters
Returns
- URL a
URL
that points to
the image to be used for this tile. If you do not wish to provide an image for this
tile coordinate, return null
.
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\u003eUrlTileProvider\u003c/code\u003e is a partial implementation of \u003ccode\u003eTileProvider\u003c/code\u003e simplifying the process of using online images as map tiles.\u003c/p\u003e\n"],["\u003cp\u003eIt requires all tile images to have the same dimensions, specified during construction.\u003c/p\u003e\n"],["\u003cp\u003eThe core functionality lies in the \u003ccode\u003egetTileUrl\u003c/code\u003e method, which you must implement to provide the URL of the image for a given tile coordinate.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eUrlTileProvider\u003c/code\u003e handles the loading of the image tile based on the URL you provide.\u003c/p\u003e\n"]]],["`UrlTileProvider` is a class requiring a URL to provide image tiles. It's constructed with image width and height. The `getTile` method retrieves the tile for specific coordinates (x, y, zoom), using the URL from `getTileUrl`. `getTileUrl` returns a URL for the tile image, or `null` if no image is available. All provided images must have identical dimensions. The `NO_TILE` constant indicates no tile for coordinates.\n"],null,["# UrlTileProvider\n\npublic abstract class **UrlTileProvider** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nimplements [TileProvider](/android/reference/com/google/android/gms/maps/model/TileProvider) \nA partial implementation of [TileProvider](/android/reference/com/google/android/gms/maps/model/TileProvider)\nthat only requires a URL that points to an image to be provided.\n\nNote that this class requires that all the images have the same dimensions. \n\n### Inherited Field Summary\n\nFrom interface [com.google.android.gms.maps.model.TileProvider](/android/reference/com/google/android/gms/maps/model/TileProvider) \n\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|\n| public static final [Tile](/android/reference/com/google/android/gms/maps/model/Tile) | [NO_TILE](/android/reference/com/google/android/gms/maps/model/TileProvider#NO_TILE) | Stub tile that is used to indicate that no tile exists for a specific tile coordinate. |\n\n### Public Constructor Summary\n\n|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [UrlTileProvider](/android/reference/com/google/android/gms/maps/model/UrlTileProvider#UrlTileProvider(int,%20int))(int width, int height) Constructs a UrlTileProvider. |\n\n### Public Method Summary\n\n|-------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| final [Tile](/android/reference/com/google/android/gms/maps/model/Tile) | [getTile](/android/reference/com/google/android/gms/maps/model/UrlTileProvider#getTile(int,%20int,%20int))(int x, int y, int zoom) Returns the [Tile](/android/reference/com/google/android/gms/maps/model/Tile) to be used for this tile coordinate. |\n| abstract [URL](//developer.android.com/reference/java/net/URL.html) | [getTileUrl](/android/reference/com/google/android/gms/maps/model/UrlTileProvider#getTileUrl(int,%20int,%20int))(int x, int y, int zoom) Returns a [URL](//developer.android.com/reference/java/net/URL.html) that points to the image to be used for this tile. |\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\nFrom interface [com.google.android.gms.maps.model.TileProvider](/android/reference/com/google/android/gms/maps/model/TileProvider) \n\n|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Tile](/android/reference/com/google/android/gms/maps/model/Tile) | [getTile](/android/reference/com/google/android/gms/maps/model/TileProvider#getTile(int,%20int,%20int))(int x, int y, int zoom) Returns the tile to be used for this tile coordinate. |\n\nPublic Constructors\n-------------------\n\n#### public **UrlTileProvider** (int width, int height)\n\nConstructs a UrlTileProvider. \n\n##### Parameters\n\n| width | width of the images used for tiles |\n| height | height of the images used for tiles |\n|--------|-------------------------------------|\n\nPublic Methods\n--------------\n\n#### public final [Tile](/android/reference/com/google/android/gms/maps/model/Tile)\n**getTile** (int x, int y, int zoom)\n\nReturns the [Tile](/android/reference/com/google/android/gms/maps/model/Tile) to be\nused for this tile coordinate. The image tile loaded through [getTileUrl(int, int, int)](/android/reference/com/google/android/gms/maps/model/UrlTileProvider#getTileUrl(int,%20int,%20int)). \n\n##### Parameters\n\n| x | The x coordinate of the tile. This will be in the range \\[0, 2^zoom^ - 1\\] inclusive. |\n| y | The y coordinate of the tile. This will be in the range \\[0, 2^zoom^ - 1\\] inclusive. |\n| zoom | The zoom level of the tile. This will be in the range \\[ [GoogleMap.getMinZoomLevel](/android/reference/com/google/android/gms/maps/GoogleMap#getMinZoomLevel()), [GoogleMap.getMaxZoomLevel](/android/reference/com/google/android/gms/maps/GoogleMap#getMaxZoomLevel())\\] inclusive. |\n|------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- The image tile loaded through [getTileUrl(int, int, int)](/android/reference/com/google/android/gms/maps/model/UrlTileProvider#getTileUrl(int,%20int,%20int)). [TileProvider.NO_TILE](/android/reference/com/google/android/gms/maps/model/TileProvider#NO_TILE) if [getTileUrl(int, int, int)](/android/reference/com/google/android/gms/maps/model/UrlTileProvider#getTileUrl(int,%20int,%20int)) is `null`; `null` if failed to load the tile. \n\n#### public abstract [URL](//developer.android.com/reference/java/net/URL.html) **getTileUrl** (int x, int y, int zoom)\n\nReturns a [URL](//developer.android.com/reference/java/net/URL.html) that points to the\nimage to be used for this tile. If no image is found on the initial request, further\nrequests will be made with an exponential backoff. If you do not wish to provide an\nimage for this tile coordinate, return null. \n\n##### Parameters\n\n| x | The x coordinate of the tile. This will be in the range \\[0, 2^zoom^ - 1\\] inclusive. |\n| y | The y coordinate of the tile. This will be in the range \\[0, 2^zoom^ - 1\\] inclusive. |\n| zoom | The zoom level of the tile. This will be in the range \\[ [GoogleMap.getMinZoomLevel](/android/reference/com/google/android/gms/maps/GoogleMap#getMinZoomLevel()), [GoogleMap.getMaxZoomLevel](/android/reference/com/google/android/gms/maps/GoogleMap#getMaxZoomLevel())\\] inclusive. |\n|------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- URL a [URL](//developer.android.com/reference/java/net/URL.html) that points to the image to be used for this tile. If you do not wish to provide an image for this tile coordinate, return `null`."]]