none
Drawing Tools - Custom Point / Line Style / Polygon Fill RRS feed

  • Question

  • HI,

    Is there a way of specifying a custom point style, polyline style and polygon line and fill style for drawings created using drawing manager?

    I currently have a very standard drawing tools implementation.

      function loadmap()
      {
        map = new Microsoft.Maps.Map(document.getElementById('map-canvas'), {
          credentials: 'My Bing Maps Key',
          center: new Microsoft.Maps.Location(52.476, -3.630),
          zoom: 8,
          mapTypeId: Microsoft.Maps.MapTypeId.ordnanceSurvey
        });
    
        //Load the AdvancedShapes module - allows polygons iwth holes in them.
        Microsoft.Maps.loadModule('Microsoft.Maps.AdvancedShapes');
    
        //Load the Well Known Text module.
        Microsoft.Maps.loadModule('Microsoft.Maps.WellKnownText', function () {
            //
        });
    
        //Load drawing tools modules.
        Microsoft.Maps.loadModule('Microsoft.Maps.DrawingTools', function () {
          tools = new Microsoft.Maps.DrawingTools(map);
          tools.showDrawingManager(function (dManager) {
            drawingManager = dManager;
            // console.log('Drawing manager loaded.');
            // console.log(drawingManager);
    
    
            drawingManager.drawingStarted.add(function () {
              console.log('Drawing started.');
              startDrawing();
            });
    
            drawingManager.drawingEnded.add(function (shape) {
              console.log('Drawing ended.');
              addShape(shape);
            });
    
            drawingManager.drawingErased.add(function () {
              console.log('Drawing erased.');
            });
    
    
          });
        });
    
      }

    Many thanks,

    Steve




    • Edited by SteveGoddard14 Tuesday, December 20, 2016 2:31 PM
    • Edited by Ricky_Brundritt Tuesday, December 20, 2016 4:26 PM Removed users Bing Maps key
    Tuesday, December 20, 2016 2:29 PM

Answers

  • Currently there is no option to change the default styles in the drawing tools. I'll add a feature request for this.

    Side note, in Bing Maps V8 you can load multiple modules in a single call like this:

    Microsoft.Maps.loadModule(['Microsoft.Maps.WellKnownText', 'Microsoft.Maps.DrawingTools'], function () {});
    This will ensure that all modules are loaded before the callback function is called which removes the chances that one module is loaded and used before another module is loaded. The modules will also be loaded in parallel for better performance. You no longer need to load the AdvanceShapes module as Polygons support holes by default in V8.


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Wednesday, December 21, 2016 9:56 AM
    • Marked as answer by SteveGoddard14 Wednesday, December 21, 2016 10:00 AM
    Wednesday, December 21, 2016 9:56 AM

All replies

  • Currently there is no option to change the default styles in the drawing tools. I'll add a feature request for this.

    Side note, in Bing Maps V8 you can load multiple modules in a single call like this:

    Microsoft.Maps.loadModule(['Microsoft.Maps.WellKnownText', 'Microsoft.Maps.DrawingTools'], function () {});
    This will ensure that all modules are loaded before the callback function is called which removes the chances that one module is loaded and used before another module is loaded. The modules will also be loaded in parallel for better performance. You no longer need to load the AdvanceShapes module as Polygons support holes by default in V8.


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Wednesday, December 21, 2016 9:56 AM
    • Marked as answer by SteveGoddard14 Wednesday, December 21, 2016 10:00 AM
    Wednesday, December 21, 2016 9:56 AM
  • Thanks Ricky - much appreciated. I've updated my code to remove advanced shapes and parallel load the other two modules.

    It would be great if the ability to define the point / line / polygon style was added. I find that the polyline is quite hard to see once drawn (particularly using UK Ordnance Survey background).

    Thanks again,

    Steve


    Steve Goddard - Biodiversity Information Service

    Wednesday, December 21, 2016 10:04 AM