Beispiel #1
0
    private string RequestImageMetadata(string locationString)
    {
        string results = "";
        string key     = "ArLeGdHOcc5h7j3L4W37oFGcU9E-LF3tAZi4o0DfhXbPJ8aiyTGbIDNHex08R2u7";

        ImageryMetadataRequest metadataRequest = new ImageryMetadataRequest();

        // Set credentials using a valid Bing Maps key
        metadataRequest.Credentials = new ImageryService.Credentials();
        metadataRequest.Credentials.ApplicationId = key;

        // Set the imagery metadata request options
        ImageryService.Location centerLocation = new ImageryService.Location();
        string[] digits = locationString.Split(',');
        centerLocation.Latitude  = double.Parse(digits[0].Trim());
        centerLocation.Longitude = double.Parse(digits[1].Trim());

        metadataRequest.Options           = new ImageryMetadataOptions();
        metadataRequest.Options.Location  = centerLocation;
        metadataRequest.Options.ZoomLevel = 10;
        metadataRequest.Style             = MapStyle.AerialWithLabels;

        // Make the imagery metadata request
        ImageryServiceClient    imageryService   = new ImageryServiceClient("BasicHttpBinding_IImageryService");
        ImageryMetadataResponse metadataResponse =
            imageryService.GetImageryMetadata(metadataRequest);

        ImageryMetadataResult result = metadataResponse.Results[0];

        if (metadataResponse.Results.Length > 0)
        {
            results = String.Format("Uri: {0}\nVintage: {1} to {2}\nZoom Levels: {3} to {4}",
                                    result.ImageUri,
                                    result.Vintage.From.ToString(),
                                    result.Vintage.To.ToString(),
                                    result.ZoomRange.From.ToString(),
                                    result.ZoomRange.To.ToString());
        }
        else
        {
            results = "Metadata is not available";
        }
        return(results);
    }
    private string RequestImageMetadata(string locationString)
    {
        string results = "";
        string key = "ArLeGdHOcc5h7j3L4W37oFGcU9E-LF3tAZi4o0DfhXbPJ8aiyTGbIDNHex08R2u7";

        ImageryMetadataRequest metadataRequest = new ImageryMetadataRequest();

        // Set credentials using a valid Bing Maps key
        metadataRequest.Credentials = new ImageryService.Credentials();
        metadataRequest.Credentials.ApplicationId = key;

        // Set the imagery metadata request options
        ImageryService.Location centerLocation = new ImageryService.Location();
        string[] digits = locationString.Split(',');
        centerLocation.Latitude = double.Parse(digits[0].Trim());
        centerLocation.Longitude = double.Parse(digits[1].Trim());

        metadataRequest.Options = new ImageryMetadataOptions();
        metadataRequest.Options.Location = centerLocation;
        metadataRequest.Options.ZoomLevel = 10;
        metadataRequest.Style = MapStyle.AerialWithLabels;

        // Make the imagery metadata request
        ImageryServiceClient imageryService = new ImageryServiceClient("BasicHttpBinding_IImageryService");
        ImageryMetadataResponse metadataResponse =
          imageryService.GetImageryMetadata(metadataRequest);

        ImageryMetadataResult result = metadataResponse.Results[0];
        if (metadataResponse.Results.Length > 0)
            results = String.Format("Uri: {0}\nVintage: {1} to {2}\nZoom Levels: {3} to {4}",
                result.ImageUri,
                result.Vintage.From.ToString(),
                result.Vintage.To.ToString(),
                result.ZoomRange.From.ToString(),
                result.ZoomRange.To.ToString());
        else
            results = "Metadata is not available";
        return results;
    }