Working with Google Earth, Part 3 – Where is the user looking at?

So, we’ve looked at generating classes from the KML schema, and we’ve looked at creating a Network Link to send our KML markup to Google Earth. Today, we’ll look at how Google Earth tells us where the user is looking at.

It turns out that they use a very simple mechanism. When the network link sends a new GET request to the server, it passes a parameter “BBOX” on the query-string. Accessing this parameter is simple:

Debug.Print(context.Request.Params["BBOX"]);

The BBOX parameter consists of a comma-separated list of 4 lines of latitude/longitude, representing west, south, east, and north respectively.

       string[] coords = 
              ((string)context.Request.Params["BBOX"]).Split(",".ToCharArray());
        double west = double.Parse(coords[0]);
        double south = double.Parse(coords[1]);
        double east = double.Parse(coords[2]);
        double north = double.Parse(coords[3]);

Using these you can limit the data you return to things the user can see.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s