TMapScreen.ScaleInPointTMapScreen |
Установить масштаб отображения и сместить центр в координату
procedure ScaleInPoint(NewScale : integer; Point : TCompMapPoint);
Описание: Метод устанавливает текущий масштаб отображения карты в NewScale и центр отображения смещает в Point. В случае Point = nil, выполняется вычисление центра окна карты (запоминается в метрах), далее выполняется масштабирование, а в качестве центра отображения устанавливается ранее вычисленная координата в метрах.
Пример плавного масштабирования колесиком мышки (пример FindObj): procedure TfrmFind.mvMapMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); var pScale1, iold : integer; begin Handled := true; iold := mvMap.ViewScale; If (iold <= 2000) then pScale1 := iold + 50 else If (iold > 2000) and (iold <= 20000) then pScale1 := iold + 500 else If (iold > 20000) and (iold <= 50000) then pScale1 := iold + 1000 else If (iold > 50000) and (iold <= 500000) then pScale1 := iold + 5000 else pScale1 := iold + 10000; mvMap.ScaleInPoint((pScale1), nil); end;
procedure TfrmFind.mvMapMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); var pScale1, iold : integer; begin Handled := true; iold := mvMap.ViewScale; If (iold <= 2000) then pScale1 := iold - 50 else If (iold > 2000) and (iold <= 20000) then pScale1 := iold - 500 else If (iold > 20000) and (iold <= 50000) then pScale1 := iold - 1000 else If (iold > 50000) and (iold <= 500000) then pScale1 := iold - 5000 else pScale1 := iold - 10000; mvMap.ScaleInPoint((pScale1), nil); end; |