O'Reilly logo

Learning Bing Maps API by Artan Sinani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pushpins

Let's stop for a minute and rethink our workflow. When the user clicks on the map, we need to show a pin, which will be a corner of the polygon. When the user double-clicks on the map, we will close the polygon. We also need to provide some visual clues as the user drags the mouse, trying to find another point.

We'll start by writing the method that adds the handlers, as shown in the following code snippet:

_addHandlers: function(self) {
  this._handlers = {};
  this._handlers.click = Microsoft.Maps.Events.addHandler(this._map, 'click', function(e) {
    self._onmapclick(e);
  });
  this._handlers.dblclick = Microsoft.Maps.Events.addHandler(this._map, 'dblclick', function(e) {
    self._onmapdblclick(e);
  });
}

We store the click and dblclick handlers on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required