Fr0sT-Brutal / Delphi_OSMMap

Visual control for Delphi and Lazarus to display OSM map
Mozilla Public License 2.0
61 stars 23 forks source link

Line #3

Closed Danxy0 closed 9 months ago

Danxy0 commented 3 years ago

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

Fr0sT-Brutal commented 3 years ago

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 :)

AlexHausauer commented 3 years ago

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

Fr0sT-Brutal commented 3 years ago

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

fabianopaolini commented 1 year ago

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?

Fr0sT-Brutal commented 1 year ago

@fabianopaolini will TMapControl.OnGetTile and OnDrawTile be sufficient?

fabianopaolini commented 1 year ago

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...).

Express2000 commented 11 months ago

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 commented 11 months ago

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

Fr0sT-Brutal commented 10 months ago

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 commented 9 months ago

Small teaser ;)

image

Fr0sT-Brutal commented 9 months ago

Done by c64175261fab18b7525b7edc76174dbf30e1ea89

Danxy0 commented 8 months ago

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