1
1

hello

I was using leaflet to get map from openstreet map and came across this.

http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png

could anyone explain it to me? I got the map but not in the right position and the right portion that i wanted

thank you

asked 20 Jun '12, 04:03

frensforall's gravatar image

frensforall
41223
accept rate: 0%

edited 24 Jun '12, 17:11

stephan75's gravatar image

stephan75
12.5k453209


Leaflet displays a map by displaying a series of tiles across the page. It needs to know where to get these tiles from and how the tiles are stored in a directory structure. The statement you quote shows leaflet how the OSM tiles are structured. If you used tiles from another source the structure would be different.

Leaflet has fairly good documentation, the part describing how the tiles are structured is here: http://leaflet.cloudmade.com/reference.html#tilelayer

permanent link

answered 20 Jun '12, 12:10

ChrisH's gravatar image

ChrisH
4.1k134262
accept rate: 15%

That line looks like the placeholder string for the url to the tiles that make up the standard layer. Leaflet will replace all the strings in curly braces '{}' to get the url for the tile it wants.

For instance http://b.tile.openstreetmap.org/8/127/85.png will give you a nice tile covering the south of england.

permanent link

answered 20 Jun '12, 07:11

Gnonthgol's gravatar image

Gnonthgol ♦
13.6k15101198
accept rate: 16%

The tile layer definition has z, x, and y in it. They're replaced with actual values whenever Leaflet needs to fetch a tile. If you've got a working map, but it's centered on the wrong, you probably just need to tell Leaflet where to centre the map.

If you look at this example, you'll see that it contains:

map.setView(new L.LatLng(51.3, 0.7),9);

It's that function call that tells Leaflet where to centre the map and at what zoom level. If you replace "51.3" with the latitude you want, "0.7" with the longitude, and 9 with the zoom level, you'll get a map centred wherever you want it.

permanent link

answered 20 Jun '12, 09:36

SomeoneElse's gravatar image

SomeoneElse ♦
32.3k63336756
accept rate: 15%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×240
×57

question asked: 20 Jun '12, 04:03

question was seen: 27,495 times

last updated: 24 Jun '12, 17:11

powered by OSQA