CanvasMap
Getting Started Tutorials 3D Reference

Adding Drawing Tools

The third Google Mercator example includes shows how to add drawing tools for rectangles, ovals, and polygons to your maps. This can be used to let the user define an area of interest on the earth for further analysis.

The OnLoad() function for this example creates a DIV element with a series of images for the user to click to select the tool. Each image calls a SelectTool() function with either a standard tool or the name of an item that is supported by the CMLayerItems class. The definitions for the standard tools are below.

The CMLayerItems class supports:

Examine the SelectTool(TheTool) function and you'll see that if a standard tool is provided, it is just set into the view. Otherwise, CMLayerItemsToolHandler object is created and set as the tool handler. There is also a button with a handler that will get the coordinates for the first item added to the layer and display it in an alert box. Now you can add editable items to your web pages and find their coordinates.