Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 7 — Extending the Google API Examples 117


map.addOverlay(new GMarker(point));
}


//]]>



As you can see, the core of the process is a function,boundingbox(), which takes the loca-
tion of the top-left and bottom-right points of the box. With this information, you can deter-
mine the location of all four corners and build an array with the five points (the four corners
and the first corner again to complete the line).


Although it is tempting to use the size and zoom level of a map to show the precise area you are
concentrating on, this also limits the utility of your map. In an example like the restaurant map,
if you display a wider map area but highlight a smaller focus area, it gives your users context and
the ability to identify how they might reach or approach a location, while still indicating the core
of your map content.


Figure 7-8 shows the results of the code in Listing 7-7: a nice box surrounds the town center of
Grantham and shows the basic limits of your guide.


FIGURE7-8: Adding a bounding box to a map.

Free download pdf