Tile URL-Function

  • Pleppo
  • Pleppo's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 1 month ago #12239 by Pleppo
Replied by Pleppo on topic Tile URL-Function
Hi,
maybe I can use the Leaflet method "LatLngBounds" and my corner coordinates in the Excel table "MTB corners geogr" or "MTB corners-GK" to create a TK25 grid (1: 25.000).

var corner1 = L.latLng(40.712, -74.227),
corner2 = L.latLng(40.774, -74.125),
bounds = L.latLngBounds(corner1, corner2);

map.fitBounds([
[40.712, -74.227],
[40.774, -74.125]
]);

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago - 5 years 1 month ago #12241 by Dima
Replied by Dima on topic Tile URL-Function
Hi.
Here you can read about tiles
developers.google.com/maps/documentation...tes#tile-coordinates
It is the same to OSM
Grid layer, which I add into extension - it is just "borders" of tiles, and numbering you can see like in google docs. It explains numbers x and y and zoom;

As for other grids - if you have grid coordinates, and want to see it over the map you can
1 - if it is not depends on zoom and you want to see every time - just try to create KML (or other) file with lines like (your_lat, -179; your, 179) - horizontal line, (-85, your_lng; 85, your_lng) - vertical
2 - if it depends on zoom - create your own map tiles for this case, upload it to server to accessible place, create your overlay map type and you can see it.

If you have sensible data (like you wrote about your file) - you can use case #2

If you have GetTileURL function for grids and want to have it - create map overlay type and add it to your map.

As for TK25 - in () I can see 1:25000, it is like grid with special coordinates, and if you have its data - you can do #1 or #2. I think overlay map type it is more flexible, but it can be payable (to remove watermarks and so on). And #1 - anyone can get file from your server, because it is accessible from net

Don't forget support my developments: post review in JED , donate , help with translation ;)
Last edit: 5 years 1 month ago by Dima.

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #12242 by Dima
Replied by Dima on topic Tile URL-Function
I can't understand. Probably you changed context.
Do you want to program?
map.fitBoundes - it is for change zoom and map center to show what you have in bounds (defined by two corners). For example, you have map on zoom 16, and 10 placemarks. By default you can't see it at once on map.
If you add it into boundes and call fitBounds - the zoom will be changed to the other value and you'll see all placemarks.
This is case for fitBounds.
The same for lines, GPX tracks and so on. Only to show it all.

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago - 5 years 1 month ago #12246 by Dima
Replied by Dima on topic Tile URL-Function
I removed substr from function (it was not fine way, because you can get different numbers after point due to different numbers before, and I substr only 10 symbols.
Now I just get up to 7 numbers after point.
If you want, there is function
function(coords) {
  var tile = L.DomUtil.create('canvas', 'leaflet-tile');
  var ctx = tile.getContext('2d');
  var size = this.getTileSize()
  tile.width = size.x
  tile.height = size.y
  
  // calculate projection coordinates of top left tile pixel
  var nwPoint = coords.scaleBy(size)
  
  // calculate geographic coordinates of top left tile pixel
  var nw = map.unproject(nwPoint, coords.z)
  
  // will not create white background
  //ctx.fillStyle = 'white';
  //ctx.fillRect(0, 0, size.x, 50);
  //ctx.fillStyle = 'black';

  var vx = " " + coords.x;
  var vy = " " + coords.y;

  ctx.fillText('x:' + vx + ', y:' + vy + ', zoom: ' + coords.z, 20, 20);

  vx = " " + parseFloat(nw.lat.toFixed(7));
  vy = " " + parseFloat(nw.lng.toFixed(7));

  ctx.fillText('lat:' + vx + ', lon:' + vy, 20, 40);

  ctx.strokeStyle = 'black';
  ctx.beginPath();
  ctx.moveTo(0, 0);
  ctx.lineTo(size.x, 0);
  ctx.lineTo(size.x, size.y);
  ctx.lineTo(0, size.y);
  ctx.closePath();
  ctx.stroke();

  return tile;
}

Don't forget support my developments: post review in JED , donate , help with translation ;)
Last edit: 5 years 1 month ago by Dima.

Please Log in or Create an account to join the conversation.

  • Pleppo
  • Pleppo's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 1 month ago #12247 by Pleppo
Replied by Pleppo on topic Tile URL-Function
Hi Dima,
sorry, my english is very scary ;-)

For the map view in the Fronent I have the map detail with the view of the country Brandenburg.
The border I have with a gpx file represented.
With the help of your tile function, a grid is displayed above the map.
Can I change the Tile function, and thus the grid, that a MTB / TK25 grid is displayed above the fixed map section?
For the view of the area of the country Brandenburg I specified in your program the coordinates of the official Bounding box (bbox = 11.268720,51.359064,14.765748,53.559119):
53.559119,14.765748; 51.359064,11.268720
The grid would then possibly look like in the screen.

I need a coordinate axis border for the map view around the map.
Maybe I have to extend your script in the tile function?

many Greetings
F.
Attachments:

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #12248 by Dima
Replied by Dima on topic Tile URL-Function
As you mean "classic" paper map view



Border of map with coordinates - I think you can't do it any methods.
You move map, and it moves with grid. You can't fix some part of map.

Don't forget support my developments: post review in JED , donate , help with translation ;)
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.160 seconds

Donate


Go to top