There is such a situation: a map with many objects (maximum 160 thousand). In order to draw them, I decided to use a picture layer. The benefit of the objects are inactive, and therefore will not need to bother with the active areas and data source. But the mechanism for creating these picture layers remained incomprehensible to me.

What we have:

1) 160 thousand tags

2) Each tag has coordinates

3) The size of the icon tags - 10x10 (may vary)

What needs to be achieved: The final tile must be a transparent image with labels arranged in accordance with their coordinates relative to this tile.

While the image preparation algorithm, I imagine something like this:

1) for each label get the tile number

2) get the coordinates of the tile, starting from its number

3) proportionally calculate the position of the label relative to the tile (in pixels)

4) group the tags inside the tile and generate a picture

There are a couple of questions:

1) How correct is this solution? maybe there are more correct and optimal options?

2) how to correctly perform calculations on the backend (coordinates of tiles, their numbers relative to global pixel coordinates). There is no access to api yandex maps on php, as I understand it, what to do? write them yourself, use other libraries?

Thank!

  • Why not an object manager? tech.yandex.ru/maps/doc/jsapi/2.1/dg/concepts/… - Reni
  • The variant with tiles is the most optimal, because In addition to what I described, you need to redraw the label image depending on the zoom. Found about the implementation to which I aspire: geo.minsvyaz.ru/#/-1/-1/9/55.87268281534533/37.59687539135742/4 The label on a small zoom has the shape of a square, on a large zoom - has the shape of a circle with proportional zoom. - Tilonorrinco
  • I will tell what I did: 1) received the coordinates of the area covering all the marks 2) received the coordinates of the extreme tiles (lower left and upper right) according to the coordinates 3) based on this data I added the grid of the area tiles 4) received the coordinates according to the number of the coordinates, translated them to other coordinates , and then I transferred these coordinates to global ones (I did not find an opportunity to directly obtain global tile coordinates) Tiles will be generated from this data on the server side. The only problem so far is that too many errors fall into the console (404, the tile was not found). I will look for a way to process them. - Tilonorrinco

1 answer 1

I had this. Also, their tiles are not always loaded. I suppose the point is that the server either does not have time to process the requests of hundreds of tiles (although it is unlikely), or numerous requests from one ip are blocked. I did this: I created one large image of my map, without breaking it into tiles. Then he added a large rectangular polygon to the map with the map as a background. If your map area is large enough, you can enter your tiles. Each tile has its own polygon. Of course, you can make your own map for different zoom.

And I would also recommend that you make caching tiles on the server (especially with rare updates). Why slow down the operation of the system with repetitive operations? If you correctly set the HTTP headers for the tiles and even get the time of the last data update, you can get a significant gain in speed.