Ricky's profileRicky's Bing Maps BlogBlogSkyDrive Tools Help

Blog


    8/16/2009

    Determine if a location has Birdseye Imagery

    fRecently I was asked how to determine if a specific area on the map has Birdseye imagery. There are several ways to do this using the AJAX control or the Web Service of Bing Maps. However, one of the clients requirements was to be able to determine this before loading a map and without having to create a web service. With this requirement it is not possible to use the built in imagery metadata functionality of the map. There is not supported method to determine if a location has Birdseye imagery without loading a map and without using the Bing Maps Web Services, however it can be done. In the series of blog posts I made called “Birdseye Imagery Extraction via the Virtual Earth Web Services” I described a method to retrieve Birdseye scene information from a background service that is used by the AJAX control. By extending some of the undocumented functionalities of the we can access this backend service through the AJAX control without loading a map. This backend service takes in an array of VEParameter objects. These parameters mush include the latitude, longitude, zoom level, spin direction, and orientation of a Birdseye request. By hard coding the zoom level to 19, the spin direction to “No Spin” and the orientation to “North” we have the highest chance of getting an accurate response as this is the most common Birdseye imagery setting. Once we have created this array we can pass it along with the URL of the backend service, and a callback function into a method called JSONRequestInvoke. In that callback the response contains a property called Scene. If this property is null then Birdseye imagery is not available for the specified location otherwise it does. Below is a basic HTML page that shows how to do this.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
       <head>
        <title>Birdseye Imagery Query</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <script src="
    http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>
        <script>
        var BEURL = "
    http://dev.virtualearth.net/services/v1/ImageryMetadataService/ImageryMetadataService.asmx/GetBirdsEyeSceneByLocation";
        function CheckBirdseye()
        {
            var lat = document.getElementById("lat").value;
            var lng = document.getElementById("lng").value;
            RequestBirdseyeMetadata(parseFloat(lat),parseFloat(lng));
        }
        function RequestBirdseyeMetadata(lat,lng)
        {   
            var params = [];
            params.push(new VEParameter("latitude",lat));
            params.push(new VEParameter("longitude",lng));
            params.push(new VEParameter("level",19));
            params.push(new VEParameter("spinDirection","\"NoSpin\""));
            params.push(new VEParameter("orientation","\"North\""));
            JSONRequestInvoke(BEURL, params, BirdseyeMetadataCallback);
        }
        function BirdseyeMetadataCallback(response)
        {
            if(response.Scene != null)
            {
                alert("There is Birdseye Imagery at this location");
            }
            else
            {
                alert("No Birdseye Imagery at this location");
            }
        }
        </script>
    </head>
    <body>
        Latitude: <INPUT id="lat" type="text"><br/>
        Longitude: <INPUT id="lng" type="text"><br/>
        <INPUT type="button" value="Check for Birdseye Imagery" onclick="CheckBirdseye();">
    </body>
    </html>


    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.
    Ricky Brundritt has turned off comments on this page.

    Trackbacks

    The trackback URL for this entry is:
    http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!958.trak
    Weblogs that reference this entry
    • None