Select to view content in your preferred language

Android - Loading a custom XYZ .png Map Tile from a URL

7966
5
04-23-2016 12:00 AM
JasonChristian
Emerging Contributor

Hello, I am new to this SDK and I'm building an android application using ArcGIS android SDK.

The problem is, I need to find out how to load a custom XYZ map tiles from a URL

(e.g. http://map.domain.com/street_map/{z}/{x}/{y}.png).

I am currently looking at extending from TiledServiceLayer and overriding the getTile(level,col,row), but I have no idea how to build it.

Some examples I've looked at:

  1. Mozilla Stumbler layer: loading TMS and XYZ tilelayers in QGIS | www.qgis.nl . The example uses the QGIS application
  2. Adding tile layers to your web map | ArcGIS Blog . The example also uses ArcGIS online
  3. Creating a custom TileServiceLayer in ArcGIS Android | ArcGIS Blog . This is probably the closest one with my problem due to the getTile() function, but I still have no idea how to implement it (e.g.. deciding envelopes, extents, and tileinfo)

If there's a sample code or a lead on how to do it, I'd greatly appreciate it

Thanks before

0 Kudos
5 Replies
EricBader
Honored Contributor

You're on the right track with #3.

Local MBTiles | ArcGIS for Developers  is a pretty good example of what I think you're trying to do.

0 Kudos
JasonChristian
Emerging Contributor

Hi,

Thank you for the reply.

According to the blog on #3, I need to decide the:

- Spatial Reference of the Data (Spherical Mercator = EPSG 3857)

- Tile Origin (x=-20037508.34, y=20037508.34 unless overridden in the

metadata)

- Number of Levels (Obtained by querying from the database)

- Available Scales (Defined by the specification)

- Available Resolutions (Defined by the specification)

- Extents of the Layer (whole world unless overridden in metadata)

I am very new to ArcGIS, so I don't know what values I should put in to

each variable. In comparison to Google Map, I only have to provide the URL

by overriding it without any data above. I'd appreciate it greatly if u can

provide the explanation to each variable and possible values for them. The

example from blog #3 takes all the value from a database, so I wouldn't

know the real value of it

Regards

0 Kudos
JasonChristian
Emerging Contributor

UPDATE: I have implemented my own class extending from TiledServiceLayer.

When I add it to my map, it does not execute the getTile() method (the

debug msg does not appear)

Here's the data that I have used:

- Spatial reference : 4326

- resolution = {0.5625, 0.28125, 0.140625, 0.0703125, 0.03515625,

0.017578125, 0.0087890625, 0.00439453125, 0.002197265625}

- scale = {2.3639807480314958E8, 1.1819903740157479E8,

5.9099518700787395E7, 2.9549759350393698E7, 1.4774879675196849E7,

7387439.837598424, 3693719.918799212, 1846859.959399606, 923429.979699803}

- zoomLevel = 9

- both extents : -180, -90, 180, 90

- DPI : 96

- tile size = 256 x 256

- The URL of the map:

http://maps.omniscale.net/v2/mobilemenschen-a4e73fda/style.default///.png

I have set all of the above data in the constructor and have called

super.initLayer(), but the getTile method wasn't called after I added to my

map layer. I couldn't provide my code at the moment, but I followed the

example from here https://community.esri.com/thread/77765, but without the

database connection ( I just added the data explicitly to the

setFullExtent(), setSpatialReference(), setTileInfo(), etc.)

Any help is appreciated, thanks before

On Wed, May 4, 2016 at 7:14 AM, Jason Christian <

0 Kudos
JasonChristian
Emerging Contributor

It seems that the link to the map is not correctly shown :

http://maps.omniscale.net/v2/mobilemenschen-a4e73fda/style.default///.png

On Thu, May 5, 2016 at 11:48 AM, Jason Christian <

0 Kudos
JerryGarcia
Frequent Contributor

Any ideas to consume ArcGIS services into MapBox JS API.  Seems to be a similar issue:

Consume ArcGIS services in Mapbox GL API?

0 Kudos