Delphi_OSMMap icon indicating copy to clipboard operation
Delphi_OSMMap copied to clipboard

Line

Open Danxy0 opened this issue 4 years ago • 5 comments

Please add a function for drawing a line from one to another coordinate.

Danxy0 avatar Sep 17 '20 13:09 Danxy0

Hi! It's obvious todo to a map view of course. Alas, it it's not that simple. Now the canvas area for the map is slightly larger than view area so the memory isn't consumed too much. But if we add lines, we'll have to draw them in any zoom value as well. And what if we zoom to x20 when map consists of 2^20 tiles and have to calculate whether any line crosses our current viewport? Currently I've no clue how to do it with more or less reasonable efforts. Plz tell me if you have ideas :)

Fr0sT-Brutal avatar Nov 28 '20 20:11 Fr0sT-Brutal

Что бы начертить линию на карте я делал следующим образом: сначала добавил два свойства для точки (имя слоя и порядковый номер точки), таким образом мы сможем, в дальнейшем, отделить одну линию от другой и знать в какой последовательности соединять точки данной линий. Сначала ставим на карте первую точку, затем указываем вторую, но перед её отображением разбиваем отрезок на множество мелких отрезков соединённых между собой. Так как координаты первой и конечной точки нам известны, то определить угол и координаты промежуточных точек будет просто (по сути нам нужно разбить один отрезок на множество мелких отрезков, что бы при масштабировании линия корректно прорисовывалась). Длину промежуточных отрезков лучше формировать динамически, которая будет зависеть от длины общей линии, так как линия на карте может быть от нескольких десятков метров до нескольких сот километров.

AlexHausauer avatar Nov 28 '20 21:11 AlexHausauer

@AlexHausauer к чему-то такому я тоже пришел, хотя с углом вариант интересный. Попробую что-то сообразить

Fr0sT-Brutal avatar Nov 29 '20 14:11 Fr0sT-Brutal

My opinion is to add a PaintBox and demand to the user to draw what he wants over the map. The need is to call the OnPaint of the PaintBox everytime it is needed and to define the coordinate limits of the paintbox. I'm very interested about similar feature... can we work to develop it?

fabianopaolini avatar Sep 14 '22 09:09 fabianopaolini

@fabianopaolini will TMapControl.OnGetTile and OnDrawTile be sufficient?

Fr0sT-Brutal avatar Sep 19 '22 16:09 Fr0sT-Brutal

I done as follows:

type TRepaintProc = Procedure (ACanvas:TCanvas) of Object; //%FP%

....

I made a local procedural variable FOnRepaint that can be valorized from outside and added at the bottom of TMapContro.PainWindow:

...

// Start %FP% if Assigned(FOnRepaint) then FOnRepaint(Canvas); // Stop %FP%

This can help to redraw over the complete bitmap (really if is called a lot of times, I think on each tile, may be?). With OnDrawTile maybe that I can resolve my problem, but the above option can be an addon (complex to divide some personalided drawings in their tile portions...).

fabianopaolini avatar Oct 06 '22 16:10 fabianopaolini

Plz tell me if you have ideas :)

How you are painting map marks now? Is it possible to reuse this mechanism for route lines?

Express2000 avatar Aug 13 '23 20:08 Express2000

А, тут можно было и на русском писать...

Express2000 avatar Aug 13 '23 20:08 Express2000

How you are painting map marks now? Is it possible to reuse this mechanism for route lines?

Map marks are self-sufficient so they don't require knowledge about other tiles. Routes do (as I explained above)

А, тут можно было и на русском писать...

Можно, но могут зайти люди из разных стран, а английский как общий знаменатель

Fr0sT-Brutal avatar Aug 21 '23 07:08 Fr0sT-Brutal

Small teaser ;)

image

Fr0sT-Brutal avatar Oct 13 '23 14:10 Fr0sT-Brutal

Done by c64175261fab18b7525b7edc76174dbf30e1ea89

Fr0sT-Brutal avatar Oct 13 '23 15:10 Fr0sT-Brutal

Great job, it works very well-. Thanks :)

Danxy0 avatar Oct 23 '23 11:10 Danxy0