none
Polyline Stroke Color RRS feed

  • Question

  • I have been using this code in v7 to import GPX tracks to the map and in v7 it produces a line in pink but in v8 the line is black (RGB 000) and the polyline.getStrokeColor() produces an object error.  I thought it was the change in the opacity from a number to a decimal.   Is this a part of the API that it not working yet or do you need to do something else to color the polyline?

    V7

    var polyline = new Microsoft.Maps.Polyline([new Microsoft.Maps.Location(pLat[a], pLon[a]),new Microsoft.Maps.Location(pLat[a-1], pLon[a-1])], {strokeColor:new Microsoft.Maps.Color(200, 255, 0, 255), strokeThickness:5});
            map.entities.push(polyline);

    V8

    var polylineColor = new Microsoft.Maps.Color(1, 255, 0, 255);
    var polyline = new Microsoft.Maps.Polyline([new Microsoft.Maps.Location(pLat[a], pLon[a]),new Microsoft.Maps.Location(pLat[a-1], pLon[a-1])], {strokeColor: polylineColor, strokeThickness: 5 });
            alert("Polyline: " + polyline.getStrokeColor() + " : " + polyline.getStrokeThickness());
            map.entities.push(polyline);

    Tuesday, April 12, 2016 7:47 AM

Answers

  • Thanks for the solution - just worked it out.  Solution - this works but RGB does not.

    //https://msdn.microsoft.com/en-us/library/system.windows.media.colors%28v=vs.110%29.aspx
            var polylineColor = 'DeepPink';
            var polyline = new Microsoft.Maps.Polyline([new Microsoft.Maps.Location(pLat[a], pLon[a]),new Microsoft.Maps.Location(pLat[a-1], pLon[a-1])], {strokeColor: polylineColor, strokeThickness: 5 });

    • Marked as answer by MJD394 Tuesday, April 12, 2016 7:45 PM
    Tuesday, April 12, 2016 7:45 PM

All replies

  • The release branch of V8 currently does not support the Color class for Polylines/Polygons. (weren't able to get it in before Build) However this has been added to the experimental branch. In the map control URL add the following URL parameter: &branch=experimental

    For example:

    http://www.bing.com/api/maps/mapcontrol?mkt=en-US&branch=experimental


    [Blog] [LinkedIn]

    Tuesday, April 12, 2016 7:37 PM
  • Thanks for the solution - just worked it out.  Solution - this works but RGB does not.

    //https://msdn.microsoft.com/en-us/library/system.windows.media.colors%28v=vs.110%29.aspx
            var polylineColor = 'DeepPink';
            var polyline = new Microsoft.Maps.Polyline([new Microsoft.Maps.Location(pLat[a], pLon[a]),new Microsoft.Maps.Location(pLat[a-1], pLon[a-1])], {strokeColor: polylineColor, strokeThickness: 5 });

    • Marked as answer by MJD394 Tuesday, April 12, 2016 7:45 PM
    Tuesday, April 12, 2016 7:45 PM