Beispiel #1
0
        public static Stream getMapImage(double?latitude, double?longitude)
        {
            const string map_credentials = "ApjKKP3xo-UePHYy4EWVj7kzRUAx40rbKSGGCzw-E_jK2YAtyhs5Na0_PunRgr2Y";

            bingMapImageryService.MapUriRequest mapUriRequest = new MapUriRequest();
            Stream imageStream = null;


            // Set credentials using a valid Bing Maps key
            mapUriRequest.Credentials = new bingMapImageryService.Credentials();
            mapUriRequest.Credentials.ApplicationId = map_credentials;                  // "ApjKKP3xo-UePHYy4EWVj7kzRUAx40rbKSGGCzw-E_jK2YAtyhs5Na0_PunRgr2Y";

            bingMapImageryService.Pushpin[] pins    = new bingMapImageryService.Pushpin[1];
            bingMapImageryService.Pushpin   pushpin = new bingMapImageryService.Pushpin();
            pushpin.Location           = new bingMapImageryService.Location();
            pushpin.Location.Latitude  = (double)latitude;
            pushpin.Location.Longitude = (double)longitude;
            pushpin.IconStyle          = "2";
            pins[0] = pushpin;

            mapUriRequest.Pushpins = pins;

            //// Set the map style and zoom level
            bingMapImageryService.MapUriOptions mapUriOptions = new bingMapImageryService.MapUriOptions();
            mapUriOptions.Style     = bingMapImageryService.MapStyle.AerialWithLabels;
            mapUriOptions.ZoomLevel = 16;

            // Set the size of the requested image to match the size of the image control
            mapUriOptions.ImageSize        = new bingMapImageryService.SizeOfint();
            mapUriOptions.ImageSize.Height = 350;
            mapUriOptions.ImageSize.Width  = 600;
            mapUriRequest.Options          = mapUriOptions;

            bingMapImageryService.ImageryServiceClient imageryService = new bingMapImageryService.ImageryServiceClient("BasicHttpBinding_IImageryService");

            // Make the image request
            bingMapImageryService.MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest);
            string mapUri = mapUriResponse.Uri;

            // get image from uri
            imageStream = downloadImage(mapUri);

            //if (imageStream != null)
            //     mapImage = Image.FromStream(imageStream);

            return(imageStream);
        }
Beispiel #2
0
        public static Stream getMapImage(double? latitude, double? longitude)
        {
            const string map_credentials = "ApjKKP3xo-UePHYy4EWVj7kzRUAx40rbKSGGCzw-E_jK2YAtyhs5Na0_PunRgr2Y";
            bingMapImageryService.MapUriRequest mapUriRequest = new MapUriRequest();
            Stream imageStream = null;

            // Set credentials using a valid Bing Maps key
            mapUriRequest.Credentials = new bingMapImageryService.Credentials();
            mapUriRequest.Credentials.ApplicationId = map_credentials;	// "ApjKKP3xo-UePHYy4EWVj7kzRUAx40rbKSGGCzw-E_jK2YAtyhs5Na0_PunRgr2Y";

                    bingMapImageryService.Pushpin[] pins = new bingMapImageryService.Pushpin[1];
            bingMapImageryService.Pushpin pushpin = new bingMapImageryService.Pushpin();
            pushpin.Location = new bingMapImageryService.Location();
            pushpin.Location.Latitude = (double)latitude;
            pushpin.Location.Longitude = (double)longitude;
            pushpin.IconStyle = "2";
            pins[0] = pushpin;

            mapUriRequest.Pushpins = pins;

            //// Set the map style and zoom level
            bingMapImageryService.MapUriOptions mapUriOptions = new bingMapImageryService.MapUriOptions();
            mapUriOptions.Style = bingMapImageryService.MapStyle.AerialWithLabels;
            mapUriOptions.ZoomLevel = 16;

            // Set the size of the requested image to match the size of the image control
            mapUriOptions.ImageSize = new bingMapImageryService.SizeOfint();
            mapUriOptions.ImageSize.Height = 350;
            mapUriOptions.ImageSize.Width = 600;
            mapUriRequest.Options = mapUriOptions;

            bingMapImageryService.ImageryServiceClient imageryService = new bingMapImageryService.ImageryServiceClient("BasicHttpBinding_IImageryService");

            // Make the image request
            bingMapImageryService.MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest);
            string mapUri = mapUriResponse.Uri;

            // get image from uri
            imageStream = downloadImage(mapUri);

            //if (imageStream != null)
            //     mapImage = Image.FromStream(imageStream);

            return imageStream;
        }