Beispiel #1
0
        /// <summary>
        /// Asynchronously gets a tile image from the Bing maps REST service.
        /// </summary>
        /// <param name="requestInformation">The tile information which is to handle the request and receive the
        /// image.</param>
        /// <param name="centerCoordinate">The geo-coordinate which should serve as the image center.</param>
        /// <param name="zoomLevel">The desired image zoom level.</param>
        /// <param name="viewType">The desired image view type.</param>
        void GetImageFromServer(TileInformation requestInformation, GeoCoordinate centerCoordinate, int zoomLevel,
                                BingMapsViewType viewType)
        {
            //// Build the request URI according to the parameters

            //Bing Maps
            string requestUri = string.Format(
                "http://dev.virtualearth.net/REST/V1/Imagery/Map/{4}/{0},{1}/{2}?mapSize={5},{6}&key={3}",
                centerCoordinate.Latitude, centerCoordinate.Longitude, zoomLevel, BingMapKey, viewType,
                (int)tileDimensions.X, (int)tileDimensions.Y);

            //Google Maps
            //string requestUri = string.Format(
            //    "http://maps.googleapis.com/maps/api/staticmap?center={0},%20{1}&zoom=17&size=640x400&sensor=false",
            //    centerCoordinate.Latitude, centerCoordinate.Longitude);

            //string requestUri = string.Format("http://maps.googleapis.com/maps/api/staticmap?center={0:F5},{1:F1}&zoom=11&size=600x400&sensor=false",36.88333, -76.3);

            //string requestUri = "http://maps.googleapis.com/maps/api/staticmap?center=36.88333,-76.3&zoom=11&size=640x400&sensor=false";

            //string blah = string.Format("test: {0}", centerCoordinate.Latitude);
            //string blah2 = string.Format("test: {0:F}", centerCoordinate.Latitude);
            //string blah3 = string.Format("test: {0:F2}", centerCoordinate.Latitude);
            //string blah4 = string.Format("test: {0:F3}", centerCoordinate.Latitude);

            // B1 = requestUri;
            // Launch the request
            requestInformation.RequestImageAync(new Uri(requestUri, UriKind.Absolute));

            pendingRequestCount++;
        }
        /// <summary>
        /// Asynchronously gets a tile image from the Bing maps REST service.
        /// </summary>
        /// <param name="requestInformation">The tile information which is to handle the request and receive the
        /// image.</param>
        /// <param name="centerCoordinate">The geo-coordinate which should serve as the image center.</param>
        /// <param name="zoomLevel">The desired image zoom level.</param>
        /// <param name="viewType">The desired image view type.</param>
        void GetImageFromServer(TileInformation requestInformation, GeoCoordinate centerCoordinate, int zoomLevel,
                                BingMapsViewType viewType)
        {
            // Build the request URI according to the parameters
            string requestUri = string.Format(
                "http://dev.virtualearth.net/REST/V1/Imagery/Map/{4}/{0},{1}/{2}?mapSize={5},{6}&key={3}",
                centerCoordinate.Latitude, centerCoordinate.Longitude, zoomLevel, BingMapKey, viewType,
                (int)tileDimensions.X, (int)tileDimensions.Y);

            // Launch the request
            requestInformation.RequestImageAync(new Uri(requestUri, UriKind.Absolute));

            pendingRequestCount++;
        }
Beispiel #3
0
        /// <summary>
        /// Handler called when the user clicks the button to change the view type.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void switchViewButton_Click(object sender, EventArgs e)
        {
            if (bingMapsViewer != null)
            {
                BingMapsViewType previousType = bingMapsViewer.ViewType;

                switch (bingMapsViewer.ViewType)
                {
                case BingMapsViewType.Aerial:
                    bingMapsViewer.ViewType = BingMapsViewType.Road;
                    break;

                case BingMapsViewType.Road:
                    bingMapsViewer.ViewType = BingMapsViewType.Aerial;
                    break;

                default:
                    break;
                }

                switchViewButton.Text = String.Format("Switch to\n{0} view", previousType);
                bingMapsViewer.RefreshImages();
            }
        }
        /// <summary>
        /// Asynchronously gets a tile image from the Bing maps REST service.
        /// </summary>
        /// <param name="requestInformation">The tile information which is to handle the request and receive the 
        /// image.</param>        
        /// <param name="centerCoordinate">The geo-coordinate which should serve as the image center.</param>
        /// <param name="zoomLevel">The desired image zoom level.</param>
        /// <param name="viewType">The desired image view type.</param>
        void GetImageFromServer(TileInformation requestInformation, GeoCoordinate centerCoordinate, int zoomLevel,
            BingMapsViewType viewType)
        {
            // Build the request URI according to the parameters
            string requestUri = string.Format(
                "http://dev.virtualearth.net/REST/V1/Imagery/Map/{4}/{0},{1}/{2}?mapSize={5},{6}&key={3}",
                centerCoordinate.Latitude, centerCoordinate.Longitude, zoomLevel, BingMapKey, viewType,
                (int)tileDimensions.X, (int)tileDimensions.Y);
            //System.Diagnostics.Debug.WriteLine(requestUri);

            // Launch the request
            requestInformation.RequestImageAync(new Uri(requestUri, UriKind.Absolute));

            pendingRequestCount++;
        }
Beispiel #5
0
 /// <summary>
 /// Refreshes the displayed images by getting them again from the REST services.
 /// </summary>
 public void RefreshImages(BingMapsViewType viewType)
 {
     ActiveTiles.ViewType = viewType;
     ActiveTiles.InitializeActiveTilePlane(CenterGeoCoordinate);
 }