Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tile size other than 256 using url with center lat/long #62

Open
lionelmazeyrat opened this issue Jan 2, 2018 · 8 comments
Open

tile size other than 256 using url with center lat/long #62

lionelmazeyrat opened this issue Jan 2, 2018 · 8 comments

Comments

@lionelmazeyrat
Copy link

lionelmazeyrat commented Jan 2, 2018

Thank you for this amazing lib !

I try to use it with goole maps static api and others provider.
With these tiles providers, we have to use a center latitude,longitude

(version 2.3 from maven)

It works well with tile of 256px with the following code, but with other tile size the map displayed is not ok.
Have you ever done some test with other tile size ??? 512 or 640, does it works ???
Is there any other change to do if the tile size change ????

MyTileFactoryInfo myTileFactoryInfo = new MyTileFactoryInfo("Google", 1, 20, 20, 256,
true,true,"https://maps.googleapis.com/maps/api/staticmap", ....

in TileFactoryInfo Class I use this code to convert x/y to lat/long

public String getTileUrl(int x, int y, int zoom)
{
	zoom = getTotalMapZoom() - zoom;
	
	double xtile = x + 0.5;
	double ytile = y + 0.5;

	double n = Math.pow(2.0,zoom);
	double lon_deg = ((xtile / n) * 360.0) - 180.0;
	double lat_rad = Math.atan(Math.sinh(Math.PI * (1 - 2 * ytile / n)));
	double lat_deg = (lat_rad * 180.0) / Math.PI;
	...

}

@msteiger
Copy link
Owner

msteiger commented Jan 3, 2018

Hello Lionel,
I do not know how google maps provides the tiles. Are you sure they are provided as 512px images?

In any case, why would you want that? Is there an advantage of using bigger tiles?

@lionelmazeyrat
Copy link
Author

lionelmazeyrat commented Jan 3, 2018

Hello Martin,
you can get googlemaps tiles with :
https://maps.googleapis.com/maps/api/staticmap&center=[LAT],[LONG]&key=[MY_KEY]&maptype=roadmap&size=256x256
Free key can be obtained at :
https://developers.google.com/maps/documentation/static-maps/?hl=de
It works well with the getTileUrl function posted above.

But with size=512x512, it doesn't works, tiles displayed are not correct.

I need to use 512x512 (or 640x640) which are the large dimension provided by google for free.

On each tile google add a watermark on the bootom, so with larger tiles this watermark is less annoying for example if the map size if around 4 tiles.

msteiger added a commit that referenced this issue Jan 7, 2018
@msteiger
Copy link
Owner

msteiger commented Jan 7, 2018

I can reproduce the problem. See the linked commit above. It looks like the tile rendering is correct.

The displayed images have overlapping content, so it's probably the computation of lat/lon values from the X and Y values that isn't correct for other tile sizes. Where did you get the formulas from?

msteiger added a commit that referenced this issue Jan 7, 2018
@lionelmazeyrat
Copy link
Author

I found the formula here :
https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Tile_bounding_box
See Python - Tile numbers to lon./lat.

@lionelmazeyrat
Copy link
Author

Hello martin, have you found some times to add support for tiles largest than 256px ???
It will be very interesting to support lots of tiles prividers with request with center lat/long (google, tomtom, herewego, mapquest,....)

@msteiger
Copy link
Owner

I investigated a little and could not find any obvious error. If you have the time, it would be great if you could have a look yourself and open a PR for it.

@lionelmazeyrat
Copy link
Author

lionelmazeyrat commented Jan 21, 2018

Thanks, I did not found where the tile size was involved or any obvious error...

@msteiger
Copy link
Owner

I found the error ... and more ... the Google Maps API aims at providing one single tile that covers the entire viewport. It therefore cuts off small bits of text reaching into the visible area. As a result the tiles are not really ... well .. tiling.

Is there anything OpenStreetMap does not cover? If so, you might want to try Nokia Here. The quality is impressive and it supports 512x512 tiles, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants