//The Imagery Service private string GetImagery(string locationString) { string key = "ApwndqJgdJ9M1Bpb7d_ihBwXW-J0N3HdXrZvFZqvFtmeYN5DewRoGPI7czgFo5Sh"; MapUriRequest mapUriRequest = new MapUriRequest(); // Set credentials using a valid Bing Maps key mapUriRequest.Credentials = new ImageryService.Credentials(); mapUriRequest.Credentials.ApplicationId = key; // Set the location of the requested image mapUriRequest.Center = new ImageryService.Location(); string[] digits = locationString.Split(','); mapUriRequest.Center.Latitude = double.Parse(digits[0].Trim()); mapUriRequest.Center.Longitude = double.Parse(digits[1].Trim()); // Set the map style and zoom level MapUriOptions mapUriOptions = new MapUriOptions(); mapUriOptions.Style = MapStyle.AerialWithLabels; mapUriOptions.ZoomLevel = 17; // Set the size of the requested image in pixels mapUriOptions.ImageSize = new ImageryService.SizeOfint(); mapUriOptions.ImageSize.Height = 200; mapUriOptions.ImageSize.Width = 300; mapUriRequest.Options = mapUriOptions; //Make the request and return the URI ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); return(mapUriResponse.Uri); }
private string GetImagery(string locationString) { string key = "ArLeGdHOcc5h7j3L4W37oFGcU9E-LF3tAZi4o0DfhXbPJ8aiyTGbIDNHex08R2u7"; MapUriRequest mapUriRequest = new MapUriRequest(); // Set credentials using a valid Bing Maps key mapUriRequest.Credentials = new ImageryService.Credentials(); mapUriRequest.Credentials.ApplicationId = key; // Set the location of the requested image mapUriRequest.Center = new ImageryService.Location(); string[] digits = locationString.Split(','); mapUriRequest.Center.Latitude = double.Parse(digits[0].Trim()); mapUriRequest.Center.Longitude = double.Parse(digits[1].Trim()); // Set the map style and zoom level MapUriOptions mapUriOptions = new MapUriOptions(); mapUriOptions.Style = MapStyle.AerialWithLabels; mapUriOptions.ZoomLevel = 17; // Set the size of the requested image in pixels mapUriOptions.ImageSize = new ImageryService.SizeOfint(); mapUriOptions.ImageSize.Height = 200; mapUriOptions.ImageSize.Width = 300; mapUriRequest.Options = mapUriOptions; //Make the request and return the URI ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); return(mapUriResponse.Uri); }
private string GetMapUri(double latitude, double longitude, int zoom, string mapStyle, int width, int height) { MvcSourceblog.ImageryServices.Pushpin[] pins = new MvcSourceblog.ImageryServices.Pushpin[1]; MvcSourceblog.ImageryServices.Pushpin pushpin = new MvcSourceblog.ImageryServices.Pushpin(); pushpin.Location = new MvcSourceblog.ImageryServices.Location(); pushpin.Location.Latitude = latitude; pushpin.Location.Longitude = longitude; pushpin.IconStyle = "2"; pins[0] = pushpin; MapUriRequest mapUriRequest = new MapUriRequest(); // Set credentials using a valid Bing Maps Key mapUriRequest.Credentials = new ImageryServices.Credentials(); mapUriRequest.Credentials.ApplicationId = "AhjlMbKnHDlgTASkyk750YRs5wR3_1gN2hEz6pahnE7Iiurq_DzrE4hDUgBxrtfN"; // Set the location of the requested image mapUriRequest.Pushpins = pins; // Set the map style and zoom level MapUriOptions mapUriOptions = new MapUriOptions(); //mapUriOptions.ZoomLevel = 17; switch (mapStyle.ToUpper()) { case "HYBRID": mapUriOptions.Style = MvcSourceblog.ImageryServices.MapStyle.AerialWithLabels; break; case "ROAD": mapUriOptions.Style = MvcSourceblog.ImageryServices.MapStyle.Road; break; case "AERIAL": mapUriOptions.Style = MvcSourceblog.ImageryServices.MapStyle.Aerial; break; case "BirdseyeWithLabels_v1": mapUriOptions.Style = MvcSourceblog.ImageryServices.MapStyle.BirdseyeWithLabels_v1; break; default: mapUriOptions.Style = MvcSourceblog.ImageryServices.MapStyle.Road; break; } mapUriOptions.ZoomLevel = 10; // Set the size of the requested image to match the size of the image control mapUriOptions.ImageSize = new MvcSourceblog.ImageryServices.SizeOfint(); mapUriOptions.ImageSize.Height = height; mapUriOptions.ImageSize.Width = width; mapUriRequest.Options = mapUriOptions; ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); return(mapUriResponse.Uri); }
async public static Task <string> GetMapUri(double latitude, double longitude, int zoom, string mapStyle, int width, int height) { var pins = new Pushpin[1]; var pushpin = new Pushpin(); pushpin.Location = new Location(); pushpin.Location.Latitude = latitude; pushpin.Location.Longitude = longitude; pushpin.IconStyle = "2"; pins[0] = pushpin; var mapUriRequest = new MapUriRequest { Credentials = new Credentials(), Pushpins = pins }; mapUriRequest.Credentials.ApplicationId = App.Self.APIKEY; var mapUriOptions = new MapUriOptions { ZoomLevel = zoom, ImageSize = new SizeOfint() }; switch (mapStyle.ToUpper()) { case "HYBRID": mapUriOptions.Style = MapStyle.AerialWithLabels; break; case "ROAD": mapUriOptions.Style = MapStyle.Road; break; case "AERIAL": mapUriOptions.Style = MapStyle.Aerial; break; default: mapUriOptions.Style = MapStyle.Road; break; } mapUriOptions.ImageSize.Height = height; mapUriOptions.ImageSize.Width = width; mapUriRequest.Options = mapUriOptions; var imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUriAsync(mapUriRequest); return(mapUriResponse.Uri); }
private string GetMapUri(double latitude, double longitude, int zoom, string mapStyle, int width, int height) { ImageryServices.Pushpin[] pins = new ImageryServices.Pushpin[1]; ImageryServices.Pushpin pushpin = new ImageryServices.Pushpin(); pushpin.Location = new ImageryServices.Location(); pushpin.Location.Latitude = latitude; pushpin.Location.Longitude = longitude; pushpin.IconStyle = "2"; pins[0] = pushpin; MapUriRequest mapUriRequest = new MapUriRequest(); // Set credentials using a valid Bing Maps Key mapUriRequest.Credentials = new ImageryServices.Credentials(); mapUriRequest.Credentials.ApplicationId = "7Xe5dWLJW6JIhH6jDYR7~6wrgqqAAstaYhxwKEyAB6g~AhB0MhPMBgrTWhG-cxBqbFxaJe92xk7oGVnJPfBckupM4wWTauJQIMkjs5Fs_Z5u"; // Set the location of the requested image mapUriRequest.Pushpins = pins; // Set the map style and zoom level MapUriOptions mapUriOptions = new MapUriOptions(); //mapUriOptions.ZoomLevel = 17; switch (mapStyle.ToUpper()) { case "HYBRID": mapUriOptions.Style = ImageryServices.MapStyle.AerialWithLabels; break; case "ROAD": mapUriOptions.Style = ImageryServices.MapStyle.Road; break; case "AERIAL": mapUriOptions.Style = ImageryServices.MapStyle.Aerial; break; default: mapUriOptions.Style = ImageryServices.MapStyle.Road; break; } mapUriOptions.ZoomLevel = 15; // Set the size of the requested image to match the size of the image control mapUriOptions.ImageSize = new ImageryServices.SizeOfint(); mapUriOptions.ImageSize.Height = height; mapUriOptions.ImageSize.Width = width; mapUriRequest.Options = mapUriOptions; ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); return(mapUriResponse.Uri); }
public string GetMapUri(double latitude, double longitude, int zoom, string mapStyle, int width, int height) { ImageryService.Pushpin[] pins = new ImageryService.Pushpin[1]; ImageryService.Pushpin pushpin = new ImageryService.Pushpin(); pushpin.Location = new ImageryService.Location(); pushpin.Location.Latitude = latitude; pushpin.Location.Longitude = longitude; pushpin.IconStyle = "2"; pins[0] = pushpin; MapUriRequest mapUriRequest = new MapUriRequest(); // Set credentials using a valid Bing Maps Key mapUriRequest.Credentials = new ImageryService.Credentials(); mapUriRequest.Credentials.ApplicationId = "AjKX5fPclkvH3YTYhLImWMour1KISHMrcFVBrXzVsjqwMLiWobOq83esCN1ra0Q0"; // Set the location of the requested image mapUriRequest.Pushpins = pins; // Set the map style and zoom level MapUriOptions mapUriOptions = new MapUriOptions(); //mapUriOptions.ZoomLevel = 17; switch (mapStyle.ToUpper()) { case "HYBRID": mapUriOptions.Style = ImageryService.MapStyle.AerialWithLabels; break; case "ROAD": mapUriOptions.Style = ImageryService.MapStyle.Road; break; case "AERIAL": mapUriOptions.Style = ImageryService.MapStyle.Aerial; break; default: mapUriOptions.Style = ImageryService.MapStyle.Road; break; } mapUriOptions.ZoomLevel = 10; // Set the size of the requested image to match the size of the image control mapUriOptions.ImageSize = new ImageryService.SizeOfint(); mapUriOptions.ImageSize.Height = height; mapUriOptions.ImageSize.Width = width; mapUriRequest.Options = mapUriOptions; ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); return(mapUriResponse.Uri); }
public static BitmapImage GetImagery(XYPoint point, double dx, double dy) { try { string key = "ArfYQbvMgvi7NOpxSAuS3lkBlVc3NqzgBcVo-yxNyr_KPVJbhwR22c9cVfG7AnwY"; MapUriRequest mapUriRequest = new MapUriRequest(); // Set credentials using a valid Bing Maps key mapUriRequest.Credentials = new Credentials(); mapUriRequest.Credentials.ApplicationId = key; // Set the location of the requested image mapUriRequest.Center = new Location(); mapUriRequest.Center.Latitude = point.Latitude; mapUriRequest.Center.Longitude = point.Longitude; // Set the map style and zoom level MapUriOptions mapUriOptions = new MapUriOptions(); mapUriOptions.Style = MapStyle.AerialWithLabels_v1; mapUriOptions.ZoomLevel = 13; // Set the size of the requested image in pixels mapUriOptions.ImageSize = new SizeOfint(); mapUriOptions.ImageSize.Height = (int)(dy / 19.11); //19.11 to get meters mapUriOptions.ImageSize.Width = (int)(dx / 19.11); mapUriRequest.Options = mapUriOptions; //Make the request and return the URI ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); return(new BitmapImage(new Uri(mapUriResponse.Uri))); } catch (Exception e) { return(null); } }
private string GetImagery(string locationString) { string key = "AnMBF3YY-9Cu2a6Og_vid1aCqNpho_WUux8hnOKgtYAK7zFR-WUtXXz31fxPNaCP"; MapUriRequest mapUriRequest = new MapUriRequest(); // Set credentials using a valid Bing Maps key mapUriRequest.Credentials = new ImageryService.Credentials(); mapUriRequest.Credentials.ApplicationId = key; // Set the location of the requested image mapUriRequest.Center = new ImageryService.Location(); string[] digits = locationString.Split(','); mapUriRequest.Center.Latitude = double.Parse(digits[0].Trim()); mapUriRequest.Center.Longitude = double.Parse(digits[1].Trim()); // Set the map style and zoom level MapUriOptions mapUriOptions = new MapUriOptions(); mapUriOptions.Style = MapStyle.AerialWithLabels; mapUriOptions.ZoomLevel = 13; // Set the size of the requested image in pixels mapUriOptions.ImageSize = new ImageryService.SizeOfint(); mapUriOptions.ImageSize.Height = 400; mapUriOptions.ImageSize.Width = 600; mapUriRequest.Options = mapUriOptions; //Make the request and return the URI ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService"); MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); return(mapUriResponse.Uri); }