Overlay Classes

Any overlay you want to add to your map needs to be implemented as a subclass of Overlay. This does not have to be a public class; TourMapActivity has a private inner class called RouteOverlay to show the waypoints and current device position.

To attach an overlay class to your map, you need to get your map's OverlayController and add the overlay to it:

map.createOverlayController().add(new RouteOverlay(this), true);

The first parameter is the Overlay instance, in this case a new RouteOverlay, attached to the activity. The second parameter is a boolean indicating if the overlay should be activated. You can define overlays and activate or deactivate them as needed, just as you toggle between regular and satellite views. In this case, since we want the overlay to be visible at all times, we use true to activate it immediately.

Self Publishing

Self Publishing

Have you always wanted to write your own book and get it published? Discover How to Write, Print Sell Your Own Book! Have you always wanted to write your own book and get it published? If you have written a book or even if you have a yen to be a writer, you are probably already aware of the competition in the writing field.

Get My Free Ebook


Post a comment