Display Drawing Toolbar on Map

This example shows how to add a drawing toolbar to the map so that the user can draw shapes.

<!DOCTYPE html>
    <meta charset="utf-8" />
	<script type='text/javascript'>
    var map, drawingManager;

    function GetMap() {
        map = new Microsoft.Maps.Map('#myMap', {});

        //Load the DrawingTools module
        Microsoft.Maps.loadModule('Microsoft.Maps.DrawingTools', function () {
            //Create an instance of the DrawingTools class and bind it to the map.
            var tools = new Microsoft.Maps.DrawingTools(map);

            //Show the drawing toolbar and enable editting on the map.
            tools.showDrawingManager(function (manager) {
                //Store a reference to the drawing manager as it will be useful later.
                drawingManager = manager;
    <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[YOUR_BING_MAPS_KEY]' async defer></script>
    <div id="myMap" style="position:relative;width:600px;height:400px;"></div>

Running this code in a browser will display a map with the drawing toolbar displayed on it. Select a shape and start drawing on the map. When drawing, press the escape button or a button on the toolbar to stop the drawing.


Try it now