Our tool will enable the users to draw custom polylines on the map, but we don't want this activity to interfere with other tasks performed on the map, such as dragging, clicking, and so on. Therefore, we need to add a button so that, when clicked, can allow the users to draw a shape on the map.
Respecting our modular system, we will give the power to add buttons to our LearningTheme
module, which generates the header holding the buttons. And we will use custom events to do that.
The AJAX Control provides a simple, but a powerful Events
object, which among others exposes two static methods: addHandler
and invoke
. The former method attaches a function to the map (and as we will see later in this book, also to polygons, pins, and other map entities) when an event, specified by an event name, is triggered. The invoke function triggers the event specified by the event name, with some optional data objects. The event names are usually click
, dblclick
, keypress
, and so on, but in fact...