private void btnReset_Click(object sender, EventArgs e) { GeoLatLng latLng = _rasterMap.FromScreenPixelToLatLng(_topLeft); GeoPoint pt = MapLayer.FromLatLngToPixel(latLng, _rasterMap.GetZoom()); _rasterMap.PanDirection((int)(pt.X % 256), (int)(pt.Y % 256)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Returns the point at the center of the rectangle. * @return the point at the center of the rectangle. */ public GeoLatLng GetCenter() { GeoPoint pt1 = MapLayer.FromLatLngToPixel(GetSouthWest(), 15); GeoPoint pt2 = MapLayer.FromLatLngToPixel(GetNorthEast(), 15); GeoPoint pt = new GeoPoint(); pt.X = pt1.X + (pt2.X - pt1.X) / 2; pt.Y = pt1.Y + (pt2.Y - pt1.Y) / 2; return(MapLayer.FromPixelToLatLng(pt, 15)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Computes the pixel coordinates of the given geographical point in the map. * @param latlng the geographical coordinates. * @return the pixel coordinates in the map. */ protected GeoPoint FromLatLngToMapPixel(GeoLatLng latlng) { GeoPoint center = MapLayer.FromLatLngToPixel(_mapCenterPt, _mapZoomLevel); GeoPoint topLeft = new GeoPoint(center.X - _mapSize.Width / 2.0, center.Y - _mapSize.Height / 2.0); GeoPoint pointPos = MapLayer.FromLatLngToPixel(latlng, _mapZoomLevel); pointPos.X -= topLeft.X; pointPos.Y -= topLeft.Y; return(new GeoPoint((int)(pointPos.X + 0.5), (int)(pointPos.Y + 0.5))); }