async void DispatchZoomMap() { //处理缩放请求 while (true) { var para = await _zoomRequests.Any(); //.FirstAsync(); if (_scaleData == 0) { _scaleData = _locator.Scale; } var zoomRate = getZoomRate(); var point = Mouse.GetPosition(_seaMapInfo.MapFrame); var mousePoint = _locator.ScreenToMap(point.X, point.Y); var oldScale = _locator.Scale; _scaleData = MapBorderInfo.CorrectionScale(_scaleData / zoomRate); var lon = _locator.Center.Lon; var lat = _locator.Center.Lat; if (true) { var rot = _scaleData / oldScale; var dy = mousePoint.Lat - _locator.Center.Lat; var dx = _locator.Center.Lon - mousePoint.Lon; lat = lat - dy * (rot - 1); lon = lon + dx * (rot - 1); } await _locator.Locate(_scaleData, lon, lat); } }
public static Task Offset(this ILocator locator, double dx, double dy) { var center = locator.MapToScreen(locator.Center.Lon, locator.Center.Lat); center.Offset(-dx, -dy); var newCenter = locator.ScreenToMap(center.X, center.Y); return(locator.Locate(locator.Scale, newCenter)); }
public static Task SetAsCenter(this ILocator locator, Point point) { var mapPoint = locator.ScreenToMap(point.X, point.Y); return(locator.SetAsCenter(mapPoint)); }