Display black background overlay around ploygon shape on bingmaps - bing-maps

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=experimental&callback=loadMapScenario' async defer></script>
<title>setPolygonRingsHTML</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
</head>
<body>
<div id='printoutPanel'></div>
<div id='myMap' style="position:relative; width:750px; height:450px;"></div>
<script type='text/javascript'>
function loadMapScenario() {
var js_array = [[new Microsoft.Maps.Location(47.708909801732, -122.33284698829), new Microsoft.Maps.Location(47.708909801732, -122.32996277166), new Microsoft.Maps.Location(47.708909801732, -122.32707855502), new Microsoft.Maps.Location(47.706137489184, -122.32419433839), new Microsoft.Maps.Location(47.703365176637, -122.32419433839), new Microsoft.Maps.Location(47.701979020363, -122.32563644671), new Microsoft.Maps.Location(47.70059286409, -122.32419433839), new Microsoft.Maps.Location(47.70059286409, -122.32275223007), new Microsoft.Maps.Location(47.697820551542, -122.31986801343), new Microsoft.Maps.Location(47.696434395269, -122.31842590512), new Microsoft.Maps.Location(47.695048238995, -122.31842590512), new Microsoft.Maps.Location(47.695048238995, -122.3169837968), new Microsoft.Maps.Location(47.693662082721, -122.31554168848), new Microsoft.Maps.Location(47.693662082721, -122.31409958016), new Microsoft.Maps.Location(47.692275926447, -122.31265747185), new Microsoft.Maps.Location(47.692275926447, -122.31121536353), new Microsoft.Maps.Location(47.690889770174, -122.30977325521), new Microsoft.Maps.Location(47.690889770174, -122.30833114689), new Microsoft.Maps.Location(47.692275926447, -122.30688903858), new Microsoft.Maps.Location(47.690889770174, -122.30544693026), new Microsoft.Maps.Location(47.6895036139, -122.30688903858), new Microsoft.Maps.Location(47.686731301353, -122.30400482194), new Microsoft.Maps.Location(47.685345145079, -122.30400482194), new Microsoft.Maps.Location(47.683958988805, -122.30544693026), new Microsoft.Maps.Location(47.682572832531, -122.30544693026), new Microsoft.Maps.Location(47.681186676258, -122.30400482194), new Microsoft.Maps.Location(47.67841436371, -122.30400482194), new Microsoft.Maps.Location(47.675642051163, -122.30400482194), new Microsoft.Maps.Location(47.674255894889, -122.30256271362), new Microsoft.Maps.Location(47.672869738616, -122.30256271362), new Microsoft.Maps.Location(47.671483582342, -122.30112060531), new Microsoft.Maps.Location(47.670097426068, -122.30112060531), new Microsoft.Maps.Location(47.668711269794, -122.29967849699), new Microsoft.Maps.Location(47.665938957247, -122.29967849699), new Microsoft.Maps.Location(47.664552800973, -122.29823638867), new Microsoft.Maps.Location(47.6631666447, -122.29823638867), new Microsoft.Maps.Location(47.660394332152, -122.29535217203), new Microsoft.Maps.Location(47.660394332152, -122.2924679554), new Microsoft.Maps.Location(47.660394332152, -122.28958373876), new Microsoft.Maps.Location(47.660394332152, -122.28814163045), new Microsoft.Maps.Location(47.659008175879, -122.28669952213), new Microsoft.Maps.Location(47.659008175879, -122.28381530549), new Microsoft.Maps.Location(47.657622019605, -122.28237319718), new Microsoft.Maps.Location(47.657622019605, -122.28093108886), new Microsoft.Maps.Location(47.656235863331, -122.27948898054), new Microsoft.Maps.Location(47.656235863331, -122.27804687222), new Microsoft.Maps.Location(47.654849707057, -122.27660476391), new Microsoft.Maps.Location(47.654849707057, -122.27516265559), new Microsoft.Maps.Location(47.653463550784, -122.27372054727), new Microsoft.Maps.Location(47.653463550784, -122.27083633063), new Microsoft.Maps.Location(47.653463550784, -122.26939422232), new Microsoft.Maps.Location(47.65207739451, -122.267952114), new Microsoft.Maps.Location(47.65207739451, -122.26651000568), new Microsoft.Maps.Location(47.649305081963, -122.26362578905), new Microsoft.Maps.Location(47.646532769415, -122.26074157241), new Microsoft.Maps.Location(47.646532769415, -122.25785735578), new Microsoft.Maps.Location(47.646532769415, -122.25497313914), new Microsoft.Maps.Location(47.643760456868, -122.2520889225), new Microsoft.Maps.Location(47.642374300594, -122.25064681419), new Microsoft.Maps.Location(47.639601988047, -122.25064681419), new Microsoft.Maps.Location(47.638215831773, -122.25064681419), new Microsoft.Maps.Location(47.635443519226, -122.25353103082), new Microsoft.Maps.Location(47.635443519226, -122.25497313914), new Microsoft.Maps.Location(47.634057362952, -122.25641524746), new Microsoft.Maps.Location(47.634057362952, -122.25929946409), new Microsoft.Maps.Location(47.634057362952, -122.26218368073), new Microsoft.Maps.Location(47.635443519226, -122.26362578905), new Microsoft.Maps.Location(47.635443519226, -122.26506789736), new Microsoft.Maps.Location(47.634057362952, -122.26651000568), new Microsoft.Maps.Location(47.634057362952, -122.267952114), new Microsoft.Maps.Location(47.632671206678, -122.26939422232), new Microsoft.Maps.Location(47.632671206678, -122.27227843895), new Microsoft.Maps.Location(47.632671206678, -122.27516265559), new Microsoft.Maps.Location(47.632671206678, -122.27804687222), new Microsoft.Maps.Location(47.632671206678, -122.28093108886), new Microsoft.Maps.Location(47.632671206678, -122.28237319718), new Microsoft.Maps.Location(47.631285050404, -122.28381530549), new Microsoft.Maps.Location(47.629898894131, -122.28237319718), new Microsoft.Maps.Location(47.628512737857, -122.28237319718), new Microsoft.Maps.Location(47.627126581583, -122.28093108886), new Microsoft.Maps.Location(47.624354269036, -122.28093108886), new Microsoft.Maps.Location(47.622968112762, -122.27948898054), new Microsoft.Maps.Location(47.620195800215, -122.27948898054), new Microsoft.Maps.Location(47.617423487667, -122.27660476391), new Microsoft.Maps.Location(47.61465117512, -122.27660476391), new Microsoft.Maps.Location(47.613265018846, -122.27516265559), new Microsoft.Maps.Location(47.611878862573, -122.27660476391), new Microsoft.Maps.Location(47.610492706299, -122.27516265559), new Microsoft.Maps.Location(47.607720393751, -122.27516265559), new Microsoft.Maps.Location(47.604948081204, -122.27516265559), new Microsoft.Maps.Location(47.604948081204, -122.27372054727), new Microsoft.Maps.Location(47.60356192493, -122.27227843895), new Microsoft.Maps.Location(47.60356192493, -122.27083633063), new Microsoft.Maps.Location(47.602175768657, -122.26939422232), new Microsoft.Maps.Location(47.602175768657, -122.267952114), new Microsoft.Maps.Location(47.599403456109, -122.26506789736), new Microsoft.Maps.Location(47.596631143562, -122.26218368073), new Microsoft.Maps.Location(47.596631143562, -122.25929946409), new Microsoft.Maps.Location(47.598017299835, -122.25785735578), new Microsoft.Maps.Location(47.598017299835, -122.25497313914), new Microsoft.Maps.Location(47.598017299835, -122.2520889225), new Microsoft.Maps.Location(47.598017299835, -122.25064681419), new Microsoft.Maps.Location(47.596631143562, -122.24920470587), new Microsoft.Maps.Location(47.596631143562, -122.24776259755), new Microsoft.Maps.Location(47.593858831014, -122.24487838092), new Microsoft.Maps.Location(47.593858831014, -122.2434362726), new Microsoft.Maps.Location(47.595244987288, -122.24199416428), new Microsoft.Maps.Location(47.595244987288, -122.23910994765), new Microsoft.Maps.Location(47.595244987288, -122.23622573101), new Microsoft.Maps.Location(47.592472674741, -122.23334151438), new Microsoft.Maps.Location(47.591086518467, -122.23189940606), new Microsoft.Maps.Location(47.589700362193, -122.23334151438), new Microsoft.Maps.Location(47.58831420592, -122.23334151438), new Microsoft.Maps.Location(47.586928049646, -122.23478362269), new Microsoft.Maps.Location(47.586928049646, -122.23622573101), new Microsoft.Maps.Location(47.585541893372, -122.23766783933), new Microsoft.Maps.Location(47.585541893372, -122.24055205596), new Microsoft.Maps.Location(47.586928049646, -122.24199416428), new Microsoft.Maps.Location(47.586928049646, -122.2434362726), new Microsoft.Maps.Location(47.585541893372, -122.2434362726), new Microsoft.Maps.Location(47.584155737098, -122.24487838092), new Microsoft.Maps.Location(47.584155737098, -122.24632048923), new Microsoft.Maps.Location(47.581383424551, -122.24920470587), new Microsoft.Maps.Location(47.581383424551, -122.2520889225), new Microsoft.Maps.Location(47.581383424551, -122.25497313914), new Microsoft.Maps.Location(47.581383424551, -122.25785735578), new Microsoft.Maps.Location(47.581383424551, -122.25929946409), new Microsoft.Maps.Location(47.582769580825, -122.26074157241), new Microsoft.Maps.Location(47.582769580825, -122.26218368073), new Microsoft.Maps.Location(47.579997268277, -122.26506789736), new Microsoft.Maps.Location(47.579997268277, -122.26651000568), new Microsoft.Maps.Location(47.57722495573, -122.26939422232), new Microsoft.Maps.Location(47.57722495573, -122.27227843895), new Microsoft.Maps.Location(47.575838799456, -122.27372054727), new Microsoft.Maps.Location(47.575838799456, -122.27660476391), new Microsoft.Maps.Location(47.575838799456, -122.27948898054), new Microsoft.Maps.Location(47.574452643182, -122.28093108886), new Microsoft.Maps.Location(47.574452643182, -122.28381530549), new Microsoft.Maps.Location(47.575838799456, -122.28525741381), new Microsoft.Maps.Location(47.575838799456, -122.28814163045), new Microsoft.Maps.Location(47.575838799456, -122.29102584708), new Microsoft.Maps.Location(47.574452643182, -122.29102584708), new Microsoft.Maps.Location(47.573066486909, -122.28958373876), new Microsoft.Maps.Location(47.570294174361, -122.28958373876), new Microsoft.Maps.Location(47.568908018088, -122.29102584708), new Microsoft.Maps.Location(47.567521861814, -122.29102584708), new Microsoft.Maps.Location(47.564749549267, -122.29391006372), new Microsoft.Maps.Location(47.563363392993, -122.29391006372), new Microsoft.Maps.Location(47.560591080445, -122.29679428035), new Microsoft.Maps.Location(47.557818767898, -122.29679428035), new Microsoft.Maps.Location(47.556432611624, -122.29535217203), new Microsoft.Maps.Location(47.553660299077, -122.29535217203), new Microsoft.Maps.Location(47.553660299077, -122.2924679554), new Microsoft.Maps.Location(47.55088798653, -122.28958373876), new Microsoft.Maps.Location(47.548115673982, -122.28669952213), new Microsoft.Maps.Location(47.546729517708, -122.28525741381), new Microsoft.Maps.Location(47.545343361435, -122.28525741381), new Microsoft.Maps.Location(47.542571048887, -122.28237319718), new Microsoft.Maps.Location(47.53979873634, -122.28237319718), new Microsoft.Maps.Location(47.537026423792, -122.28237319718), new Microsoft.Maps.Location(47.535640267519, -122.28093108886), new Microsoft.Maps.Location(47.532867954971, -122.28093108886), new Microsoft.Maps.Location(47.531481798698, -122.28093108886), new Microsoft.Maps.Location(47.530095642424, -122.27948898054), new Microsoft.Maps.Location(47.52870948615, -122.27948898054), new Microsoft.Maps.Location(47.527323329877, -122.28093108886), new Microsoft.Maps.Location(47.525937173603, -122.28093108886), new Microsoft.Maps.Location(47.524551017329, -122.28237319718), new Microsoft.Maps.Location(47.523164861055, -122.28093108886), new Microsoft.Maps.Location(47.520392548508, -122.28093108886), new Microsoft.Maps.Location(47.519006392234, -122.28237319718), new Microsoft.Maps.Location(47.517620235961, -122.28093108886), new Microsoft.Maps.Location(47.516234079687, -122.28093108886), new Microsoft.Maps.Location(47.513461767139, -122.28381530549), new Microsoft.Maps.Location(47.512075610866, -122.28525741381), new Microsoft.Maps.Location(47.512075610866, -122.28814163045), new Microsoft.Maps.Location(47.512075610866, -122.29102584708), new Microsoft.Maps.Location(47.513461767139, -122.2924679554), new Microsoft.Maps.Location(47.513461767139, -122.29391006372), new Microsoft.Maps.Location(47.514847923413, -122.29535217203), new Microsoft.Maps.Location(47.516234079687, -122.29535217203), new Microsoft.Maps.Location(47.516234079687, -122.29679428035), new Microsoft.Maps.Location(47.519006392234, -122.29967849699), new Microsoft.Maps.Location(47.521778704782, -122.29967849699), new Microsoft.Maps.Location(47.521778704782, -122.30112060531), new Microsoft.Maps.Location(47.524551017329, -122.30400482194), new Microsoft.Maps.Location(47.527323329877, -122.30688903858), new Microsoft.Maps.Location(47.527323329877, -122.30833114689), new Microsoft.Maps.Location(47.530095642424, -122.31121536353), new Microsoft.Maps.Location(47.530095642424, -122.31409958016), new Microsoft.Maps.Location(47.531481798698, -122.31554168848), new Microsoft.Maps.Location(47.531481798698, -122.3169837968), new Microsoft.Maps.Location(47.534254111245, -122.31986801343), new Microsoft.Maps.Location(47.535640267519, -122.32131012175), new Microsoft.Maps.Location(47.537026423792, -122.32131012175), new Microsoft.Maps.Location(47.538412580066, -122.32275223007), new Microsoft.Maps.Location(47.538412580066, -122.32563644671), new Microsoft.Maps.Location(47.53979873634, -122.32707855502), new Microsoft.Maps.Location(47.53979873634, -122.32996277166), new Microsoft.Maps.Location(47.542571048887, -122.33284698829), new Microsoft.Maps.Location(47.542571048887, -122.33428909661), new Microsoft.Maps.Location(47.545343361435, -122.33717331325), new Microsoft.Maps.Location(47.546729517708, -122.33717331325), new Microsoft.Maps.Location(47.548115673982, -122.33861542156), new Microsoft.Maps.Location(47.548115673982, -122.34005752988), new Microsoft.Maps.Location(47.55088798653, -122.34294174652), new Microsoft.Maps.Location(47.55088798653, -122.34438385484), new Microsoft.Maps.Location(47.553660299077, -122.34726807147), new Microsoft.Maps.Location(47.556432611624, -122.35015228811), new Microsoft.Maps.Location(47.557818767898, -122.35159439642), new Microsoft.Maps.Location(47.559204924172, -122.35159439642), new Microsoft.Maps.Location(47.561977236719, -122.35447861306), new Microsoft.Maps.Location(47.563363392993, -122.35592072138), new Microsoft.Maps.Location(47.564749549267, -122.35592072138), new Microsoft.Maps.Location(47.56613570554, -122.35736282969), new Microsoft.Maps.Location(47.56613570554, -122.36024704633), new Microsoft.Maps.Location(47.56613570554, -122.36168915465), new Microsoft.Maps.Location(47.568908018088, -122.36457337128), new Microsoft.Maps.Location(47.570294174361, -122.3660154796), new Microsoft.Maps.Location(47.571680330635, -122.3660154796), new Microsoft.Maps.Location(47.573066486909, -122.36457337128), new Microsoft.Maps.Location(47.574452643182, -122.36457337128), new Microsoft.Maps.Location(47.575838799456, -122.36313126296), new Microsoft.Maps.Location(47.575838799456, -122.36024704633), new Microsoft.Maps.Location(47.578611112004, -122.36024704633), new Microsoft.Maps.Location(47.579997268277, -122.36168915465), new Microsoft.Maps.Location(47.582769580825, -122.36168915465), new Microsoft.Maps.Location(47.585541893372, -122.36168915465), new Microsoft.Maps.Location(47.586928049646, -122.36024704633), new Microsoft.Maps.Location(47.589700362193, -122.36024704633), new Microsoft.Maps.Location(47.591086518467, -122.36024704633), new Microsoft.Maps.Location(47.592472674741, -122.35880493801), new Microsoft.Maps.Location(47.593858831014, -122.35880493801), new Microsoft.Maps.Location(47.595244987288, -122.35736282969), new Microsoft.Maps.Location(47.598017299835, -122.35736282969), new Microsoft.Maps.Location(47.600789612383, -122.36024704633), new Microsoft.Maps.Location(47.600789612383, -122.36313126296), new Microsoft.Maps.Location(47.602175768657, -122.36457337128), new Microsoft.Maps.Location(47.602175768657, -122.3660154796), new Microsoft.Maps.Location(47.604948081204, -122.36889969624), new Microsoft.Maps.Location(47.604948081204, -122.37034180455), new Microsoft.Maps.Location(47.607720393751, -122.37322602119), new Microsoft.Maps.Location(47.609106550025, -122.37466812951), new Microsoft.Maps.Location(47.609106550025, -122.37611023782), new Microsoft.Maps.Location(47.611878862573, -122.37899445446), new Microsoft.Maps.Location(47.61465117512, -122.38187867109), new Microsoft.Maps.Location(47.616037331394, -122.38187867109), new Microsoft.Maps.Location(47.617423487667, -122.38332077941), new Microsoft.Maps.Location(47.620195800215, -122.38332077941), new Microsoft.Maps.Location(47.622968112762, -122.38332077941), new Microsoft.Maps.Location(47.624354269036, -122.38332077941), new Microsoft.Maps.Location(47.62574042531, -122.38187867109), new Microsoft.Maps.Location(47.627126581583, -122.38187867109), new Microsoft.Maps.Location(47.629898894131, -122.38476288773), new Microsoft.Maps.Location(47.632671206678, -122.38476288773), new Microsoft.Maps.Location(47.634057362952, -122.38332077941), new Microsoft.Maps.Location(47.635443519226, -122.38332077941), new Microsoft.Maps.Location(47.636829675499, -122.38187867109), new Microsoft.Maps.Location(47.636829675499, -122.38043656278), new Microsoft.Maps.Location(47.638215831773, -122.37899445446), new Microsoft.Maps.Location(47.638215831773, -122.37611023782), new Microsoft.Maps.Location(47.638215831773, -122.37322602119), new Microsoft.Maps.Location(47.638215831773, -122.37034180455), new Microsoft.Maps.Location(47.636829675499, -122.36889969624), new Microsoft.Maps.Location(47.636829675499, -122.3660154796), new Microsoft.Maps.Location(47.639601988047, -122.36313126296), new Microsoft.Maps.Location(47.639601988047, -122.36024704633), new Microsoft.Maps.Location(47.64098814432, -122.35880493801), new Microsoft.Maps.Location(47.642374300594, -122.35880493801), new Microsoft.Maps.Location(47.643760456868, -122.35736282969), new Microsoft.Maps.Location(47.645146613141, -122.35736282969), new Microsoft.Maps.Location(47.647918925689, -122.35447861306), new Microsoft.Maps.Location(47.649305081963, -122.35303650474), new Microsoft.Maps.Location(47.649305081963, -122.35159439642), new Microsoft.Maps.Location(47.650691238236, -122.35303650474), new Microsoft.Maps.Location(47.65207739451, -122.35303650474), new Microsoft.Maps.Location(47.654849707057, -122.35015228811), new Microsoft.Maps.Location(47.654849707057, -122.34871017979), new Microsoft.Maps.Location(47.656235863331, -122.34726807147), new Microsoft.Maps.Location(47.654849707057, -122.34582596315), new Microsoft.Maps.Location(47.654849707057, -122.34438385484), new Microsoft.Maps.Location(47.657622019605, -122.34726807147), new Microsoft.Maps.Location(47.659008175879, -122.34871017979), new Microsoft.Maps.Location(47.661780488426, -122.34871017979), new Microsoft.Maps.Location(47.6631666447, -122.34871017979), new Microsoft.Maps.Location(47.665938957247, -122.34582596315), new Microsoft.Maps.Location(47.668711269794, -122.34294174652), new Microsoft.Maps.Location(47.671483582342, -122.34294174652), new Microsoft.Maps.Location(47.672869738616, -122.3414996382), new Microsoft.Maps.Location(47.674255894889, -122.3414996382), new Microsoft.Maps.Location(47.675642051163, -122.34005752988), new Microsoft.Maps.Location(47.677028207437, -122.34005752988), new Microsoft.Maps.Location(47.679800519984, -122.33717331325), new Microsoft.Maps.Location(47.681186676258, -122.33861542156), new Microsoft.Maps.Location(47.683958988805, -122.33861542156), new Microsoft.Maps.Location(47.686731301353, -122.33861542156), new Microsoft.Maps.Location(47.688117457626, -122.33861542156), new Microsoft.Maps.Location(47.6895036139, -122.34005752988), new Microsoft.Maps.Location(47.690889770174, -122.34005752988), new Microsoft.Maps.Location(47.692275926447, -122.33861542156), new Microsoft.Maps.Location(47.693662082721, -122.34005752988), new Microsoft.Maps.Location(47.695048238995, -122.34005752988), new Microsoft.Maps.Location(47.696434395269, -122.33861542156), new Microsoft.Maps.Location(47.697820551542, -122.33861542156), new Microsoft.Maps.Location(47.70059286409, -122.33573120493), new Microsoft.Maps.Location(47.701979020363, -122.33428909661), new Microsoft.Maps.Location(47.701979020363, -122.33284698829), new Microsoft.Maps.Location(47.704751332911, -122.33573120493), new Microsoft.Maps.Location(47.706137489184, -122.33573120493), new Microsoft.Maps.Location(47.708909801732, -122.33284698829)], [new Microsoft.Maps.Location(47.639601988047, -122.2434362726), new Microsoft.Maps.Location(47.639601988047, -122.24199416428), new Microsoft.Maps.Location(47.638215831773, -122.24055205596), new Microsoft.Maps.Location(47.636829675499, -122.24199416428), new Microsoft.Maps.Location(47.636829675499, -122.2434362726), new Microsoft.Maps.Location(47.638215831773, -122.24487838092), new Microsoft.Maps.Location(47.639601988047, -122.2434362726)], [new Microsoft.Maps.Location(47.58831420592, -122.22613097279), new Microsoft.Maps.Location(47.58831420592, -122.22324675615), new Microsoft.Maps.Location(47.585541893372, -122.22036253952), new Microsoft.Maps.Location(47.584155737098, -122.22036253952), new Microsoft.Maps.Location(47.581383424551, -122.22324675615), new Microsoft.Maps.Location(47.581383424551, -122.22613097279), new Microsoft.Maps.Location(47.584155737098, -122.22901518942), new Microsoft.Maps.Location(47.585541893372, -122.22901518942), new Microsoft.Maps.Location(47.58831420592, -122.22613097279)], [new Microsoft.Maps.Location(47.513461767139, -122.28237319718), new Microsoft.Maps.Location(47.510689454592, -122.27948898054), new Microsoft.Maps.Location(47.509303298318, -122.27948898054), new Microsoft.Maps.Location(47.506530985771, -122.28237319718), new Microsoft.Maps.Location(47.506530985771, -122.28381530549), new Microsoft.Maps.Location(47.509303298318, -122.28669952213), new Microsoft.Maps.Location(47.510689454592, -122.28669952213), new Microsoft.Maps.Location(47.512075610866, -122.28525741381), new Microsoft.Maps.Location(47.512075610866, -122.28381530549), new Microsoft.Maps.Location(47.513461767139, -122.28237319718)], [new Microsoft.Maps.Location(47.506530985771, -122.27948898054), new Microsoft.Maps.Location(47.505144829497, -122.27804687222), new Microsoft.Maps.Location(47.503758673224, -122.27948898054), new Microsoft.Maps.Location(47.505144829497, -122.28093108886), new Microsoft.Maps.Location(47.506530985771, -122.27948898054)]];
var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials: 'key',
center: new Microsoft.Maps.Location(47.6062095, -122.3320708), zoom: 11});
var polygoncolor = Microsoft.Maps.Color.fromHex('#0ca312');
var polygon = new Microsoft.Maps.Polygon(js_array, {fillColor: 'rgba(111,111,111,0.5)', strokeColor: polygoncolor, strokeThickness: 5});
map.entities.push(polygon);
}
</script>
</body>
The above code is my polygon shape on bing maps, using this i am getting black color inside the shape but i want the black overlay around the shape like attached imageenter image description here
Please help me out to achieve this.

What you are trying to create is known as an opacity mask. To do this you need to basically create a polygon of the whole world and cut a hole in it. There is a code sample that does this here: http://bingmapsv8samples.azurewebsites.net/#North%20Carolina%20Map
It's actually fairly easy to do with V8. you just need to make the first right in your polygon include the whole world. Here is an updated version of your code:
<!DOCTYPE html>
<html>
<head>
<title>setPolygonRingsHTML</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
</head>
<body>
<div id='myMap' style="position:relative; width:750px; height:450px;"></div>
<script type='text/javascript'>
function loadMapScenario() {
var js_array = [[new Microsoft.Maps.Location(-85, -180),new Microsoft.Maps.Location(-85, 180),new Microsoft.Maps.Location(85, 180),new Microsoft.Maps.Location(85, -180)],
[new Microsoft.Maps.Location(47.708909801732, -122.33284698829), new Microsoft.Maps.Location(47.708909801732, -122.32996277166), new Microsoft.Maps.Location(47.708909801732, -122.32707855502), new Microsoft.Maps.Location(47.706137489184, -122.32419433839), new Microsoft.Maps.Location(47.703365176637, -122.32419433839), new Microsoft.Maps.Location(47.701979020363, -122.32563644671), new Microsoft.Maps.Location(47.70059286409, -122.32419433839), new Microsoft.Maps.Location(47.70059286409, -122.32275223007), new Microsoft.Maps.Location(47.697820551542, -122.31986801343), new Microsoft.Maps.Location(47.696434395269, -122.31842590512), new Microsoft.Maps.Location(47.695048238995, -122.31842590512), new Microsoft.Maps.Location(47.695048238995, -122.3169837968), new Microsoft.Maps.Location(47.693662082721, -122.31554168848), new Microsoft.Maps.Location(47.693662082721, -122.31409958016), new Microsoft.Maps.Location(47.692275926447, -122.31265747185), new Microsoft.Maps.Location(47.692275926447, -122.31121536353), new Microsoft.Maps.Location(47.690889770174, -122.30977325521), new Microsoft.Maps.Location(47.690889770174, -122.30833114689), new Microsoft.Maps.Location(47.692275926447, -122.30688903858), new Microsoft.Maps.Location(47.690889770174, -122.30544693026), new Microsoft.Maps.Location(47.6895036139, -122.30688903858), new Microsoft.Maps.Location(47.686731301353, -122.30400482194), new Microsoft.Maps.Location(47.685345145079, -122.30400482194), new Microsoft.Maps.Location(47.683958988805, -122.30544693026), new Microsoft.Maps.Location(47.682572832531, -122.30544693026), new Microsoft.Maps.Location(47.681186676258, -122.30400482194), new Microsoft.Maps.Location(47.67841436371, -122.30400482194), new Microsoft.Maps.Location(47.675642051163, -122.30400482194), new Microsoft.Maps.Location(47.674255894889, -122.30256271362), new Microsoft.Maps.Location(47.672869738616, -122.30256271362), new Microsoft.Maps.Location(47.671483582342, -122.30112060531), new Microsoft.Maps.Location(47.670097426068, -122.30112060531), new Microsoft.Maps.Location(47.668711269794, -122.29967849699), new Microsoft.Maps.Location(47.665938957247, -122.29967849699), new Microsoft.Maps.Location(47.664552800973, -122.29823638867), new Microsoft.Maps.Location(47.6631666447, -122.29823638867), new Microsoft.Maps.Location(47.660394332152, -122.29535217203), new Microsoft.Maps.Location(47.660394332152, -122.2924679554), new Microsoft.Maps.Location(47.660394332152, -122.28958373876), new Microsoft.Maps.Location(47.660394332152, -122.28814163045), new Microsoft.Maps.Location(47.659008175879, -122.28669952213), new Microsoft.Maps.Location(47.659008175879, -122.28381530549), new Microsoft.Maps.Location(47.657622019605, -122.28237319718), new Microsoft.Maps.Location(47.657622019605, -122.28093108886), new Microsoft.Maps.Location(47.656235863331, -122.27948898054), new Microsoft.Maps.Location(47.656235863331, -122.27804687222), new Microsoft.Maps.Location(47.654849707057, -122.27660476391), new Microsoft.Maps.Location(47.654849707057, -122.27516265559), new Microsoft.Maps.Location(47.653463550784, -122.27372054727), new Microsoft.Maps.Location(47.653463550784, -122.27083633063), new Microsoft.Maps.Location(47.653463550784, -122.26939422232), new Microsoft.Maps.Location(47.65207739451, -122.267952114), new Microsoft.Maps.Location(47.65207739451, -122.26651000568), new Microsoft.Maps.Location(47.649305081963, -122.26362578905), new Microsoft.Maps.Location(47.646532769415, -122.26074157241), new Microsoft.Maps.Location(47.646532769415, -122.25785735578), new Microsoft.Maps.Location(47.646532769415, -122.25497313914), new Microsoft.Maps.Location(47.643760456868, -122.2520889225), new Microsoft.Maps.Location(47.642374300594, -122.25064681419), new Microsoft.Maps.Location(47.639601988047, -122.25064681419), new Microsoft.Maps.Location(47.638215831773, -122.25064681419), new Microsoft.Maps.Location(47.635443519226, -122.25353103082), new Microsoft.Maps.Location(47.635443519226, -122.25497313914), new Microsoft.Maps.Location(47.634057362952, -122.25641524746), new Microsoft.Maps.Location(47.634057362952, -122.25929946409), new Microsoft.Maps.Location(47.634057362952, -122.26218368073), new Microsoft.Maps.Location(47.635443519226, -122.26362578905), new Microsoft.Maps.Location(47.635443519226, -122.26506789736), new Microsoft.Maps.Location(47.634057362952, -122.26651000568), new Microsoft.Maps.Location(47.634057362952, -122.267952114), new Microsoft.Maps.Location(47.632671206678, -122.26939422232), new Microsoft.Maps.Location(47.632671206678, -122.27227843895), new Microsoft.Maps.Location(47.632671206678, -122.27516265559), new Microsoft.Maps.Location(47.632671206678, -122.27804687222), new Microsoft.Maps.Location(47.632671206678, -122.28093108886), new Microsoft.Maps.Location(47.632671206678, -122.28237319718), new Microsoft.Maps.Location(47.631285050404, -122.28381530549), new Microsoft.Maps.Location(47.629898894131, -122.28237319718), new Microsoft.Maps.Location(47.628512737857, -122.28237319718), new Microsoft.Maps.Location(47.627126581583, -122.28093108886), new Microsoft.Maps.Location(47.624354269036, -122.28093108886), new Microsoft.Maps.Location(47.622968112762, -122.27948898054), new Microsoft.Maps.Location(47.620195800215, -122.27948898054), new Microsoft.Maps.Location(47.617423487667, -122.27660476391), new Microsoft.Maps.Location(47.61465117512, -122.27660476391), new Microsoft.Maps.Location(47.613265018846, -122.27516265559), new Microsoft.Maps.Location(47.611878862573, -122.27660476391), new Microsoft.Maps.Location(47.610492706299, -122.27516265559), new Microsoft.Maps.Location(47.607720393751, -122.27516265559), new Microsoft.Maps.Location(47.604948081204, -122.27516265559), new Microsoft.Maps.Location(47.604948081204, -122.27372054727), new Microsoft.Maps.Location(47.60356192493, -122.27227843895), new Microsoft.Maps.Location(47.60356192493, -122.27083633063), new Microsoft.Maps.Location(47.602175768657, -122.26939422232), new Microsoft.Maps.Location(47.602175768657, -122.267952114), new Microsoft.Maps.Location(47.599403456109, -122.26506789736), new Microsoft.Maps.Location(47.596631143562, -122.26218368073), new Microsoft.Maps.Location(47.596631143562, -122.25929946409), new Microsoft.Maps.Location(47.598017299835, -122.25785735578), new Microsoft.Maps.Location(47.598017299835, -122.25497313914), new Microsoft.Maps.Location(47.598017299835, -122.2520889225), new Microsoft.Maps.Location(47.598017299835, -122.25064681419), new Microsoft.Maps.Location(47.596631143562, -122.24920470587), new Microsoft.Maps.Location(47.596631143562, -122.24776259755), new Microsoft.Maps.Location(47.593858831014, -122.24487838092), new Microsoft.Maps.Location(47.593858831014, -122.2434362726), new Microsoft.Maps.Location(47.595244987288, -122.24199416428), new Microsoft.Maps.Location(47.595244987288, -122.23910994765), new Microsoft.Maps.Location(47.595244987288, -122.23622573101), new Microsoft.Maps.Location(47.592472674741, -122.23334151438), new Microsoft.Maps.Location(47.591086518467, -122.23189940606), new Microsoft.Maps.Location(47.589700362193, -122.23334151438), new Microsoft.Maps.Location(47.58831420592, -122.23334151438), new Microsoft.Maps.Location(47.586928049646, -122.23478362269), new Microsoft.Maps.Location(47.586928049646, -122.23622573101), new Microsoft.Maps.Location(47.585541893372, -122.23766783933), new Microsoft.Maps.Location(47.585541893372, -122.24055205596), new Microsoft.Maps.Location(47.586928049646, -122.24199416428), new Microsoft.Maps.Location(47.586928049646, -122.2434362726), new Microsoft.Maps.Location(47.585541893372, -122.2434362726), new Microsoft.Maps.Location(47.584155737098, -122.24487838092), new Microsoft.Maps.Location(47.584155737098, -122.24632048923), new Microsoft.Maps.Location(47.581383424551, -122.24920470587), new Microsoft.Maps.Location(47.581383424551, -122.2520889225), new Microsoft.Maps.Location(47.581383424551, -122.25497313914), new Microsoft.Maps.Location(47.581383424551, -122.25785735578), new Microsoft.Maps.Location(47.581383424551, -122.25929946409), new Microsoft.Maps.Location(47.582769580825, -122.26074157241), new Microsoft.Maps.Location(47.582769580825, -122.26218368073), new Microsoft.Maps.Location(47.579997268277, -122.26506789736), new Microsoft.Maps.Location(47.579997268277, -122.26651000568), new Microsoft.Maps.Location(47.57722495573, -122.26939422232), new Microsoft.Maps.Location(47.57722495573, -122.27227843895), new Microsoft.Maps.Location(47.575838799456, -122.27372054727), new Microsoft.Maps.Location(47.575838799456, -122.27660476391), new Microsoft.Maps.Location(47.575838799456, -122.27948898054), new Microsoft.Maps.Location(47.574452643182, -122.28093108886), new Microsoft.Maps.Location(47.574452643182, -122.28381530549), new Microsoft.Maps.Location(47.575838799456, -122.28525741381), new Microsoft.Maps.Location(47.575838799456, -122.28814163045), new Microsoft.Maps.Location(47.575838799456, -122.29102584708), new Microsoft.Maps.Location(47.574452643182, -122.29102584708), new Microsoft.Maps.Location(47.573066486909, -122.28958373876), new Microsoft.Maps.Location(47.570294174361, -122.28958373876), new Microsoft.Maps.Location(47.568908018088, -122.29102584708), new Microsoft.Maps.Location(47.567521861814, -122.29102584708), new Microsoft.Maps.Location(47.564749549267, -122.29391006372), new Microsoft.Maps.Location(47.563363392993, -122.29391006372), new Microsoft.Maps.Location(47.560591080445, -122.29679428035), new Microsoft.Maps.Location(47.557818767898, -122.29679428035), new Microsoft.Maps.Location(47.556432611624, -122.29535217203), new Microsoft.Maps.Location(47.553660299077, -122.29535217203), new Microsoft.Maps.Location(47.553660299077, -122.2924679554), new Microsoft.Maps.Location(47.55088798653, -122.28958373876), new Microsoft.Maps.Location(47.548115673982, -122.28669952213), new Microsoft.Maps.Location(47.546729517708, -122.28525741381), new Microsoft.Maps.Location(47.545343361435, -122.28525741381), new Microsoft.Maps.Location(47.542571048887, -122.28237319718), new Microsoft.Maps.Location(47.53979873634, -122.28237319718), new Microsoft.Maps.Location(47.537026423792, -122.28237319718), new Microsoft.Maps.Location(47.535640267519, -122.28093108886), new Microsoft.Maps.Location(47.532867954971, -122.28093108886), new Microsoft.Maps.Location(47.531481798698, -122.28093108886), new Microsoft.Maps.Location(47.530095642424, -122.27948898054), new Microsoft.Maps.Location(47.52870948615, -122.27948898054), new Microsoft.Maps.Location(47.527323329877, -122.28093108886), new Microsoft.Maps.Location(47.525937173603, -122.28093108886), new Microsoft.Maps.Location(47.524551017329, -122.28237319718), new Microsoft.Maps.Location(47.523164861055, -122.28093108886), new Microsoft.Maps.Location(47.520392548508, -122.28093108886), new Microsoft.Maps.Location(47.519006392234, -122.28237319718), new Microsoft.Maps.Location(47.517620235961, -122.28093108886), new Microsoft.Maps.Location(47.516234079687, -122.28093108886), new Microsoft.Maps.Location(47.513461767139, -122.28381530549), new Microsoft.Maps.Location(47.512075610866, -122.28525741381), new Microsoft.Maps.Location(47.512075610866, -122.28814163045), new Microsoft.Maps.Location(47.512075610866, -122.29102584708), new Microsoft.Maps.Location(47.513461767139, -122.2924679554), new Microsoft.Maps.Location(47.513461767139, -122.29391006372), new Microsoft.Maps.Location(47.514847923413, -122.29535217203), new Microsoft.Maps.Location(47.516234079687, -122.29535217203), new Microsoft.Maps.Location(47.516234079687, -122.29679428035), new Microsoft.Maps.Location(47.519006392234, -122.29967849699), new Microsoft.Maps.Location(47.521778704782, -122.29967849699), new Microsoft.Maps.Location(47.521778704782, -122.30112060531), new Microsoft.Maps.Location(47.524551017329, -122.30400482194), new Microsoft.Maps.Location(47.527323329877, -122.30688903858), new Microsoft.Maps.Location(47.527323329877, -122.30833114689), new Microsoft.Maps.Location(47.530095642424, -122.31121536353), new Microsoft.Maps.Location(47.530095642424, -122.31409958016), new Microsoft.Maps.Location(47.531481798698, -122.31554168848), new Microsoft.Maps.Location(47.531481798698, -122.3169837968), new Microsoft.Maps.Location(47.534254111245, -122.31986801343), new Microsoft.Maps.Location(47.535640267519, -122.32131012175), new Microsoft.Maps.Location(47.537026423792, -122.32131012175), new Microsoft.Maps.Location(47.538412580066, -122.32275223007), new Microsoft.Maps.Location(47.538412580066, -122.32563644671), new Microsoft.Maps.Location(47.53979873634, -122.32707855502), new Microsoft.Maps.Location(47.53979873634, -122.32996277166), new Microsoft.Maps.Location(47.542571048887, -122.33284698829), new Microsoft.Maps.Location(47.542571048887, -122.33428909661), new Microsoft.Maps.Location(47.545343361435, -122.33717331325), new Microsoft.Maps.Location(47.546729517708, -122.33717331325), new Microsoft.Maps.Location(47.548115673982, -122.33861542156), new Microsoft.Maps.Location(47.548115673982, -122.34005752988), new Microsoft.Maps.Location(47.55088798653, -122.34294174652), new Microsoft.Maps.Location(47.55088798653, -122.34438385484), new Microsoft.Maps.Location(47.553660299077, -122.34726807147), new Microsoft.Maps.Location(47.556432611624, -122.35015228811), new Microsoft.Maps.Location(47.557818767898, -122.35159439642), new Microsoft.Maps.Location(47.559204924172, -122.35159439642), new Microsoft.Maps.Location(47.561977236719, -122.35447861306), new Microsoft.Maps.Location(47.563363392993, -122.35592072138), new Microsoft.Maps.Location(47.564749549267, -122.35592072138), new Microsoft.Maps.Location(47.56613570554, -122.35736282969), new Microsoft.Maps.Location(47.56613570554, -122.36024704633), new Microsoft.Maps.Location(47.56613570554, -122.36168915465), new Microsoft.Maps.Location(47.568908018088, -122.36457337128), new Microsoft.Maps.Location(47.570294174361, -122.3660154796), new Microsoft.Maps.Location(47.571680330635, -122.3660154796), new Microsoft.Maps.Location(47.573066486909, -122.36457337128), new Microsoft.Maps.Location(47.574452643182, -122.36457337128), new Microsoft.Maps.Location(47.575838799456, -122.36313126296), new Microsoft.Maps.Location(47.575838799456, -122.36024704633), new Microsoft.Maps.Location(47.578611112004, -122.36024704633), new Microsoft.Maps.Location(47.579997268277, -122.36168915465), new Microsoft.Maps.Location(47.582769580825, -122.36168915465), new Microsoft.Maps.Location(47.585541893372, -122.36168915465), new Microsoft.Maps.Location(47.586928049646, -122.36024704633), new Microsoft.Maps.Location(47.589700362193, -122.36024704633), new Microsoft.Maps.Location(47.591086518467, -122.36024704633), new Microsoft.Maps.Location(47.592472674741, -122.35880493801), new Microsoft.Maps.Location(47.593858831014, -122.35880493801), new Microsoft.Maps.Location(47.595244987288, -122.35736282969), new Microsoft.Maps.Location(47.598017299835, -122.35736282969), new Microsoft.Maps.Location(47.600789612383, -122.36024704633), new Microsoft.Maps.Location(47.600789612383, -122.36313126296), new Microsoft.Maps.Location(47.602175768657, -122.36457337128), new Microsoft.Maps.Location(47.602175768657, -122.3660154796), new Microsoft.Maps.Location(47.604948081204, -122.36889969624), new Microsoft.Maps.Location(47.604948081204, -122.37034180455), new Microsoft.Maps.Location(47.607720393751, -122.37322602119), new Microsoft.Maps.Location(47.609106550025, -122.37466812951), new Microsoft.Maps.Location(47.609106550025, -122.37611023782), new Microsoft.Maps.Location(47.611878862573, -122.37899445446), new Microsoft.Maps.Location(47.61465117512, -122.38187867109), new Microsoft.Maps.Location(47.616037331394, -122.38187867109), new Microsoft.Maps.Location(47.617423487667, -122.38332077941), new Microsoft.Maps.Location(47.620195800215, -122.38332077941), new Microsoft.Maps.Location(47.622968112762, -122.38332077941), new Microsoft.Maps.Location(47.624354269036, -122.38332077941), new Microsoft.Maps.Location(47.62574042531, -122.38187867109), new Microsoft.Maps.Location(47.627126581583, -122.38187867109), new Microsoft.Maps.Location(47.629898894131, -122.38476288773), new Microsoft.Maps.Location(47.632671206678, -122.38476288773), new Microsoft.Maps.Location(47.634057362952, -122.38332077941), new Microsoft.Maps.Location(47.635443519226, -122.38332077941), new Microsoft.Maps.Location(47.636829675499, -122.38187867109), new Microsoft.Maps.Location(47.636829675499, -122.38043656278), new Microsoft.Maps.Location(47.638215831773, -122.37899445446), new Microsoft.Maps.Location(47.638215831773, -122.37611023782), new Microsoft.Maps.Location(47.638215831773, -122.37322602119), new Microsoft.Maps.Location(47.638215831773, -122.37034180455), new Microsoft.Maps.Location(47.636829675499, -122.36889969624), new Microsoft.Maps.Location(47.636829675499, -122.3660154796), new Microsoft.Maps.Location(47.639601988047, -122.36313126296), new Microsoft.Maps.Location(47.639601988047, -122.36024704633), new Microsoft.Maps.Location(47.64098814432, -122.35880493801), new Microsoft.Maps.Location(47.642374300594, -122.35880493801), new Microsoft.Maps.Location(47.643760456868, -122.35736282969), new Microsoft.Maps.Location(47.645146613141, -122.35736282969), new Microsoft.Maps.Location(47.647918925689, -122.35447861306), new Microsoft.Maps.Location(47.649305081963, -122.35303650474), new Microsoft.Maps.Location(47.649305081963, -122.35159439642), new Microsoft.Maps.Location(47.650691238236, -122.35303650474), new Microsoft.Maps.Location(47.65207739451, -122.35303650474), new Microsoft.Maps.Location(47.654849707057, -122.35015228811), new Microsoft.Maps.Location(47.654849707057, -122.34871017979), new Microsoft.Maps.Location(47.656235863331, -122.34726807147), new Microsoft.Maps.Location(47.654849707057, -122.34582596315), new Microsoft.Maps.Location(47.654849707057, -122.34438385484), new Microsoft.Maps.Location(47.657622019605, -122.34726807147), new Microsoft.Maps.Location(47.659008175879, -122.34871017979), new Microsoft.Maps.Location(47.661780488426, -122.34871017979), new Microsoft.Maps.Location(47.6631666447, -122.34871017979), new Microsoft.Maps.Location(47.665938957247, -122.34582596315), new Microsoft.Maps.Location(47.668711269794, -122.34294174652), new Microsoft.Maps.Location(47.671483582342, -122.34294174652), new Microsoft.Maps.Location(47.672869738616, -122.3414996382), new Microsoft.Maps.Location(47.674255894889, -122.3414996382), new Microsoft.Maps.Location(47.675642051163, -122.34005752988), new Microsoft.Maps.Location(47.677028207437, -122.34005752988), new Microsoft.Maps.Location(47.679800519984, -122.33717331325), new Microsoft.Maps.Location(47.681186676258, -122.33861542156), new Microsoft.Maps.Location(47.683958988805, -122.33861542156), new Microsoft.Maps.Location(47.686731301353, -122.33861542156), new Microsoft.Maps.Location(47.688117457626, -122.33861542156), new Microsoft.Maps.Location(47.6895036139, -122.34005752988), new Microsoft.Maps.Location(47.690889770174, -122.34005752988), new Microsoft.Maps.Location(47.692275926447, -122.33861542156), new Microsoft.Maps.Location(47.693662082721, -122.34005752988), new Microsoft.Maps.Location(47.695048238995, -122.34005752988), new Microsoft.Maps.Location(47.696434395269, -122.33861542156), new Microsoft.Maps.Location(47.697820551542, -122.33861542156), new Microsoft.Maps.Location(47.70059286409, -122.33573120493), new Microsoft.Maps.Location(47.701979020363, -122.33428909661), new Microsoft.Maps.Location(47.701979020363, -122.33284698829), new Microsoft.Maps.Location(47.704751332911, -122.33573120493), new Microsoft.Maps.Location(47.706137489184, -122.33573120493), new Microsoft.Maps.Location(47.708909801732, -122.33284698829)],
[new Microsoft.Maps.Location(47.639601988047, -122.2434362726), new Microsoft.Maps.Location(47.639601988047, -122.24199416428), new Microsoft.Maps.Location(47.638215831773, -122.24055205596), new Microsoft.Maps.Location(47.636829675499, -122.24199416428), new Microsoft.Maps.Location(47.636829675499, -122.2434362726), new Microsoft.Maps.Location(47.638215831773, -122.24487838092), new Microsoft.Maps.Location(47.639601988047, -122.2434362726)],
[new Microsoft.Maps.Location(47.58831420592, -122.22613097279), new Microsoft.Maps.Location(47.58831420592, -122.22324675615), new Microsoft.Maps.Location(47.585541893372, -122.22036253952), new Microsoft.Maps.Location(47.584155737098, -122.22036253952), new Microsoft.Maps.Location(47.581383424551, -122.22324675615), new Microsoft.Maps.Location(47.581383424551, -122.22613097279), new Microsoft.Maps.Location(47.584155737098, -122.22901518942), new Microsoft.Maps.Location(47.585541893372, -122.22901518942), new Microsoft.Maps.Location(47.58831420592, -122.22613097279)],
[new Microsoft.Maps.Location(47.513461767139, -122.28237319718), new Microsoft.Maps.Location(47.510689454592, -122.27948898054), new Microsoft.Maps.Location(47.509303298318, -122.27948898054), new Microsoft.Maps.Location(47.506530985771, -122.28237319718), new Microsoft.Maps.Location(47.506530985771, -122.28381530549), new Microsoft.Maps.Location(47.509303298318, -122.28669952213), new Microsoft.Maps.Location(47.510689454592, -122.28669952213), new Microsoft.Maps.Location(47.512075610866, -122.28525741381), new Microsoft.Maps.Location(47.512075610866, -122.28381530549), new Microsoft.Maps.Location(47.513461767139, -122.28237319718)],
[new Microsoft.Maps.Location(47.506530985771, -122.27948898054), new Microsoft.Maps.Location(47.505144829497, -122.27804687222), new Microsoft.Maps.Location(47.503758673224, -122.27948898054), new Microsoft.Maps.Location(47.505144829497, -122.28093108886), new Microsoft.Maps.Location(47.506530985771, -122.27948898054)]];
var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials: 'key',
center: new Microsoft.Maps.Location(47.6062095, -122.3320708), zoom: 11});
var polygon = new Microsoft.Maps.Polygon(js_array, {fillColor: 'rgba(111,111,111,0.5)', strokeColor: '#0ca312', strokeThickness: 5});
map.entities.push(polygon);
}
</script>
<script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=experimental&callback=loadMapScenario' async defer>

Related

IOException during splitting java.util.concurrent.ExecutionException: java.io.FileNotFoundException when loading HFile to HBase

I am trying to bulk load data into hbase using the salted table approach as stated in this site: https://www.opencore.com/blog/2016/10/efficient-bulk-load-of-hbase-using-spark/. While I am able to insert data but at random times I get
ERROR mapreduce.LoadIncrementalHFiles: IOException during splitting
java.util.concurrent.ExecutionException: java.io.FileNotFoundException: File does not exist: /user//hfile/transactions/transaction_data/b1c6c47856104db0a1289c2b7234d1d7
I am using hbase-client 1.2.0 and hbase-server 1.2.0 as dependencies and using HFileOutputFormat2 class to write my HFile.
I tried using the writer's patch HFileOutputFormat2 https://github.com/gbif/maps/commit/ee4e0001486f3e8b37b034c5b05fc8c8d4e76ab9 but this will fail to write the HFile all together.
Below is the code portion that writes the HFile and loads it to hbase
dates.map { x =>
val hbase_connection2 = ConnectionFactory.createConnection(hbaseconfig)
val table2 = hbase_connection2.getTable(TableName.valueOf(hbase_table))
val regionLoc2 = hbase_connection2.getRegionLocator(table2.getName)
val admin2 = hbase_connection2.getAdmin
val transactionsDF = sql(hive_query_2.replace("|columns|", hive_columns) + " " + period_clause.replace("|date|", date_format.format(x)))
val max_records = transactionsDF.count()
val max_page = math.ceil(max_records.toDouble/page_limit.toDouble).toInt
val start_row = 0
val end_row = page_limit.toInt
val start_page = if(date_format.format(x).equals(bookmark_date)) {
bookmarked_page
}
else{
0
}
val pages = start_page to (if(max_records < page_limit.toInt){max_page-1}else{max_page})
if(max_records > 0) {
pages.map (page => {
val sourceDF = transactionsDF
.withColumn("tanggal", cnvrt_tanggal(transactionsDF.col("ctry_cd"), transactionsDF.col("ori_tanggal"), transactionsDF.col("ori_jam")))
.withColumn("jam", cnvrt_jam(transactionsDF.col("ctry_cd"), transactionsDF.col("ori_tanggal"), transactionsDF.col("ori_jam")))
.join(locations, transactionsDF.col("wsid") === locations.col("key"), "left_outer")
.join(trandescdictionary, lower(transactionsDF.col("source_system")) === lower(trandescdictionary.col("FLAG_TRANS")) && lower(transactionsDF.col("trans_cd")) === lower(trandescdictionary.col("TRAN_CODE")), "left_outer")
.filter(transactionsDF.col("rowid").between((start_row + (page * page_limit.toInt)).toString, ((end_row + (page * page_limit.toInt)) - 1).toString))
.withColumn("uuid", timeUUID())
.withColumn("created_dt", current_timestamp())
val spp = new SaltPrefixPartitioner(hbase_regions)
val saltedRDD = sourceDF.rdd.flatMap(r => {
Seq((salt(r.getString(r.fieldIndex("uuid")), hbase_regions), Seq(r.get(r.fieldIndex(new String(cols(0).toLowerCase))), r.get(r.fieldIndex(new String(cols(1).toLowerCase))), r.get(r.fieldIndex(new String(cols(2).toLowerCase))), r.get(r.fieldIndex(new String(cols(3).toLowerCase))), r.get(r.fieldIndex(new String(cols(4).toLowerCase))), r.get(r.fieldIndex(new String(cols(5).toLowerCase))), r.get(r.fieldIndex(new String(cols(6).toLowerCase))), r.get(r.fieldIndex(new String(cols(7).toLowerCase))), r.get(r.fieldIndex(new String(cols(8).toLowerCase))), r.get(r.fieldIndex(new String(cols(9).toLowerCase))), r.get(r.fieldIndex(new String(cols(10).toLowerCase))), r.get(r.fieldIndex(new String(cols(11).toLowerCase))), r.get(r.fieldIndex(new String(cols(12).toLowerCase))), r.get(r.fieldIndex(new String(cols(13).toLowerCase))), r.get(r.fieldIndex(new String(cols(14).toLowerCase))), r.get(r.fieldIndex(new String(cols(15).toLowerCase))), r.get(r.fieldIndex(new String(cols(16).toLowerCase))), r.get(r.fieldIndex(new String(cols(17).toLowerCase))), r.get(r.fieldIndex(new String(cols(18).toLowerCase))), r.get(r.fieldIndex(new String(cols(19).toLowerCase))), r.get(r.fieldIndex(new String(cols(20).toLowerCase))), r.get(r.fieldIndex(new String(cols(21).toLowerCase))), r.get(r.fieldIndex(new String(cols(22).toLowerCase))))))
})
val partitionedRDD = saltedRDD.repartitionAndSortWithinPartitions(spp)
val cells = partitionedRDD.flatMap(r => {
val salted_keys = r._1
val colFamily = hbase_colfamily
Seq(
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(0).getBytes(), Bytes.toBytes(Option(r._2(0)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(1).getBytes(), Bytes.toBytes(Option(r._2(1)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(2).getBytes(), Bytes.toBytes(Option(r._2(2)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(3).getBytes(), Bytes.toBytes(Option(r._2(3)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(4).getBytes(), Bytes.toBytes(Option(r._2(4)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(5).getBytes(), Bytes.toBytes(Option(r._2(5)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(6).getBytes(), Bytes.toBytes(Option(r._2(6)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(7).getBytes(), Bytes.toBytes(Option(r._2(7)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(8).getBytes(), Bytes.toBytes(Option(r._2(8)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(9).getBytes(), Bytes.toBytes(Option(r._2(9)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(10).getBytes(), Bytes.toBytes(Option(r._2(10)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(11).getBytes(), Bytes.toBytes(Option(r._2(11)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(12).getBytes(), Bytes.toBytes(Option(r._2(12)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(13).getBytes(), Bytes.toBytes(Option(r._2(13)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(14).getBytes(), Bytes.toBytes(Option(r._2(14)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(15).getBytes(), Bytes.toBytes(Option(r._2(15)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(16).getBytes(), Bytes.toBytes(Option(r._2(16)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(17).getBytes(), Bytes.toBytes(Option(r._2(17)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(18).getBytes(), Bytes.toBytes(Option(r._2(18)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(19).getBytes(), Bytes.toBytes(Option(r._2(19)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(20).getBytes(), Bytes.toBytes(Option(r._2(20)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(21).getBytes(), Bytes.toBytes(Option(r._2(21)).getOrElse("").toString))),
(new ImmutableBytesWritable(Bytes.toBytes(salted_keys)), new KeyValue(Bytes.toBytes(salted_keys), colFamily.getBytes(), cols(22).getBytes(), Bytes.toBytes(Option(r._2(22)).getOrElse("").toString)))
)
})
val job = Job.getInstance(hbaseconfig, "Insert Transaction Data Row " + (start_row + (page * page_limit.toInt)).toString + " to " + ((end_row + (page * page_limit.toInt)) - 1).toString + " for " + x.toString)
HFileOutputFormat2.configureIncrementalLoad(job, table2, regionLoc2)
val conf = job.getConfiguration
if (fs.exists(path)) {
fs.delete(path, true)
cells.saveAsNewAPIHadoopFile(
path.toString,
classOf[ImmutableBytesWritable],
classOf[KeyValue],
classOf[HFileOutputFormat2],
conf
)
}
else if (!fs.exists(path)) {
cells.saveAsNewAPIHadoopFile(
path.toString,
classOf[ImmutableBytesWritable],
classOf[KeyValue],
classOf[HFileOutputFormat2],
conf
)
}
val bulk_loader = new LoadIncrementalHFiles(conf)
bulk_loader.doBulkLoad(path, admin2, table2, regionLoc2)
conf.clear()
println("Done For " + x.toString + " pages " + (start_row + (page * page_limit.toInt)).toString + " to " + ((end_row + (page * page_limit.toInt)) - 1).toString)
if (fs.exists(bookmark)) {
fs.delete(bookmark, true)
Seq((date_format.format(x), page.toString)).map(r => (r._1, r._2)).toDF("Date", "Page").write.format("com.databricks.spark.csv").option("delimiter", "|").save(bookmark_path)
}
else {
Seq((date_format.format(x), page.toString)).map(r => (r._1, r._2)).toDF("Date", "Page").write.format("com.databricks.spark.csv").option("delimiter", "|").save(bookmark_path)
}
0
})
}
hbase_connection2.close()
0
}
I am really at my wits end as I could not trace what is causing this error. I hope someone can give me some ideas on what could be the cause of this file splitting error.
I think you may be seeing this:
https://issues.apache.org/jira/projects/HBASE/issues/HBASE-21183
It is something I saw sporadically, so we never solved it. How regularly do you see it please?
HBASE-3871 seems like you have to parllelize and repartition your data is the solution for this.
see this code which is the orgin for the error
private Pair<Multimap<ByteBuffer, LoadQueueItem>, Set<String>> groupOrSplitPhase(
AsyncClusterConnection conn, TableName tableName, ExecutorService pool,
Deque<LoadQueueItem> queue, List<Pair<byte[], byte[]>> startEndKeys) throws IOException {
// <region start key, LQI> need synchronized only within this scope of this
// phase because of the puts that happen in futures.
Multimap<ByteBuffer, LoadQueueItem> rgs = HashMultimap.create();
final Multimap<ByteBuffer, LoadQueueItem> regionGroups = Multimaps.synchronizedMultimap(rgs);
Set<String> missingHFiles = new HashSet<>();
Pair<Multimap<ByteBuffer, LoadQueueItem>, Set<String>> pair =
new Pair<>(regionGroups, missingHFiles);
// drain LQIs and figure out bulk load groups
Set<Future<Pair<List<LoadQueueItem>, String>>> splittingFutures = new HashSet<>();
while (!queue.isEmpty()) {
final LoadQueueItem item = queue.remove();
final Callable<Pair<List<LoadQueueItem>, String>> call =
new Callable<Pair<List<LoadQueueItem>, String>>() {
#Override
public Pair<List<LoadQueueItem>, String> call() throws Exception {
Pair<List<LoadQueueItem>, String> splits =
groupOrSplit(conn, tableName, regionGroups, item, startEndKeys);
return splits;
}
};
splittingFutures.add(pool.submit(call));
}
// get all the results. All grouping and splitting must finish before
// we can attempt the atomic loads.
for (Future<Pair<List<LoadQueueItem>, String>> lqis : splittingFutures) {
try {
Pair<List<LoadQueueItem>, String> splits = lqis.get();
if (splits != null) {
if (splits.getFirst() != null) {
queue.addAll(splits.getFirst());
} else {
missingHFiles.add(splits.getSecond());
}
}
} catch (ExecutionException e1) {
Throwable t = e1.getCause();
if (t instanceof IOException) {
LOG.error("IOException during splitting", e1);
throw (IOException) t; // would have been thrown if not parallelized,
}
LOG.error("Unexpected execution exception during splitting", e1);
throw new IllegalStateException(t);
} catch (InterruptedException e1) {
LOG.error("Unexpected interrupted exception during splitting", e1);
throw (InterruptedIOException) new InterruptedIOException().initCause(e1);
}
}
return pair;
}

ITextSharp v5.5.13.0 XMLWorker Turkish character problem

I used iTextSharp and all Turkish character disappeared.
Also html inline css attributes work on table element but not working on div element.
I tried lots of encoding convert sample code but not found any results.
My sample code:
public static byte[] HtmlToPdfItextSharp(string HTMLCONTENTSTRING, List<string> cssFiles = null)
{
using (var ms = new MemoryStream())
{
Document pdfDoc = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10);
BaseFont STF_Helvetica_Turkish = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, "CP1254", BaseFont.NOT_EMBEDDED);
Font fontNormal = new Font(STF_Helvetica_Turkish, 12, Font.NORMAL, BaseColor.BLACK);
string fontPath = Path.Combine(Path.Combine(Server.MapPath("~/App_Data/Pdf/arial.ttf")));
XMLWorkerFontProvider fontProvider = new XMLWorkerFontProvider(XMLWorkerFontProvider.DONTLOOKFORFONTS);
fontProvider.UseUnicode = true;
fontProvider.Register(fontPath);
CssAppliers ca = new CssAppliersImpl(fontProvider);
var pdfWriter = PdfWriter.GetInstance(pdfDoc, ms);
pdfDoc.Open();
pdfWriter.DirectContent.SetFontAndSize(STF_Helvetica_Turkish, 12);
pdfWriter.CloseStream = false;
var htmlContext = new HtmlPipelineContext(null);
htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(false);
cssFiles.ForEach(e => cssResolver.AddCssFile(e, true));
var pp = new PdfWriterPipeline(pdfDoc, pdfWriter);
IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, pp));
XMLWorker worker = new XMLWorker(pipeline, true);
XMLParser parser = new XMLParser(worker);
parser.Parse(new MemoryStream(Encoding.UTF8.GetBytes(HTMLCONTENTSTRING)));
pdfDoc.Close();
return ms.GetBuffer();
}
}
I updated my code and add stylesheet file (with font familiy:arial;) and i solved character
but it takes too long time
My new updated function like:
public static byte[] HtmlToPdfItextSharp(string HTMLCONTENTSTRING, List<string> cssFiles = null)
{
using (var ms= new MemoryStream())
{
Document pdfDoc = new Document(PageSize.A4.Rotate(), 10, 10, 7, 10);
var pdfWriter = PdfWriter.GetInstance(pdfDoc, ms);
pdfWriter.CloseStream = false;
pdfDoc.Open();
var htmlContext = new HtmlPipelineContext(null);
htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(false);
cssFiles.ForEach(e => cssResolver.AddCssFile(e, true));
var pp = new PdfWriterPipeline(pdfDoc, pdfWriter);
IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, pp));
XMLWorker worker = new XMLWorker(pipeline, true);
XMLParser parser = new XMLParser(worker);
parser.Parse(new MemoryStream(Encoding.UTF8.GetBytes(pHtmlIcerik)));
pdfDoc.Close();
return ms.ToArray();
}
}
Css code :
body {
font-family:Arial;
}
table{
font-family:Arial;
}
td{
font-family:Arial;
}

How can to show the row number in Nebula NatTable

I can show a CSV content to a NatTable using those code:
IDataProvider bodyDataProvider = ...;
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
viewportLayer.setRegionName(GridRegion.BODY);
natTable.setLayer(viewportLayer);
How can we show the row number? I tried to used GridLayer but there are no column header. Please help!
I resolved this. I used CompositeLayer:
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
DataLayer rowHeaderDataLayer = new DataLayer(rowHeaderDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(
rowHeaderDataLayer,
viewportLayer,
selectionLayer);
CompositeLayer compositeLayer = new CompositeLayer(2, 1);
compositeLayer.setChildLayer(GridRegion.ROW_HEADER, rowHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 1, 0);
natTable.setLayer(compositeLayer);

SWT CTabFolder doesn't display when running from eclipse

I am creating an app using WindowBuilder in eclipse 4.4.2. I've added CTabFolders and corresponding CTabItems. The tabs are displayed properly when Click the preview button(Quickly test/preview the window without compiling or running it) in windowbuilder.
Screen Shot===> http://i.imgur.com/Sx9TQrL.jpg
But the real problem is when I run the app,the tabs are not displayed.
Screen Shot===> http://i.imgur.com/OP7WY8W.jpg
Code
public class Dashboard {
public static void main(String[] args) {
Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setImage(SWTResourceManager.getImage(Dashboard.class,
"/com/sun/java/swing/plaf/windows/icons/Computer.gif"));
shell.setBackground(SWTResourceManager
.getColor(SWT.COLOR_WIDGET_BORDER));
shell.setSize(1080, 700);
shell.setLayout(new GridLayout(2, false));
/**
* Base Layout
* **/
Composite content = new Composite(shell, SWT.BORDER);
content.setBackground(SWTResourceManager
.getColor(SWT.COLOR_WIDGET_BACKGROUND));
content.setLayout(new StackLayout());
// content.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
// false));
content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final CTabFolder tabFolder = new CTabFolder(content, SWT.CLOSE);
tabFolder.setTabHeight(28);
tabFolder.setSimple(false);
tabFolder.setSelectionForeground(SWTResourceManager
.getColor(SWT.COLOR_BLACK));
tabFolder.setBackground(SWTResourceManager
.getColor(SWT.COLOR_WIDGET_BACKGROUND));
tabFolder.setSelectionBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
CTabItem homeTab = new CTabItem(tabFolder, SWT.NONE);
homeTab.setText("Home");
Composite composite_4 = new Composite(tabFolder, SWT.NONE);
homeTab.setControl(composite_4);
Label lblHome = new Label(composite_4, SWT.NONE);
lblHome.setBounds(185, 105, 55, 15);
lblHome.setText("Home");
final CTabItem empTab = new CTabItem(tabFolder, SWT.CLOSE);
empTab.setImage(SWTResourceManager.getImage(
Dashboard.class, "/resource/icons/employee.png"));
empTab.setText("Employees");
Composite composite_5 = new Composite(tabFolder, SWT.NONE);
empTab.setControl(composite_5);
Label lblEmployees = new Label(composite_5, SWT.NONE);
lblEmployees.setBounds(155, 102, 55, 15);
lblEmployees.setText("Employees");
CTabItem workTab = new CTabItem(tabFolder, SWT.CLOSE);
workTab.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/worksite.png"));
workTab.setText("Work Site");
Composite composite_6 = new Composite(tabFolder, SWT.NONE);
workTab.setControl(composite_6);
Label lblWorkSite = new Label(composite_6, SWT.NONE);
lblWorkSite.setBounds(222, 123, 55, 15);
lblWorkSite.setText("Work site");
CTabItem paymentTab = new CTabItem(tabFolder, SWT.NONE);
paymentTab.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/payments.png"));
paymentTab.setText("Payments");
Composite composite_7 = new Composite(tabFolder, SWT.NONE);
paymentTab.setControl(composite_7);
Label lblPayments = new Label(composite_7, SWT.NONE);
lblPayments.setBounds(185, 176, 55, 15);
lblPayments.setText("Payments");
CTabItem toolsTab = new CTabItem(tabFolder, SWT.NONE);
toolsTab.setImage(SWTResourceManager.getImage(Dashboard.class, "/resource/icons/tools.png"));
toolsTab.setShowClose(true);
toolsTab.setText("Tools");
Composite composite_8 = new Composite(tabFolder, SWT.NONE);
toolsTab.setControl(composite_8);
Label lblTools = new Label(composite_8, SWT.NONE);
lblTools.setBounds(264, 125, 55, 15);
lblTools.setText("Tools");
/**
* MenuBar
* **/
Menu menu = new Menu(shell, SWT.BAR);
shell.setMenuBar(menu);
MenuItem mntmFile = new MenuItem(menu, SWT.CASCADE);
mntmFile.setImage(null);
mntmFile.setText("File");
Menu menu_1 = new Menu(mntmFile);
mntmFile.setMenu(menu_1);
MenuItem mntmExit = new MenuItem(menu_1, SWT.NONE);
mntmExit.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
shell.dispose();
}
});
mntmExit.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/close.png"));
mntmExit.setText("Exit");
MenuItem mntmHelp = new MenuItem(menu, SWT.CASCADE);
mntmHelp.setText("Help");
Menu menu_2 = new Menu(mntmHelp);
mntmHelp.setMenu(menu_2);
MenuItem mntmAbout = new MenuItem(menu_2, SWT.NONE);
mntmAbout.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
About abdialog = new About(shell, 0);
abdialog.open();
}
});
mntmAbout.setText("About");
Composite sidebar = new Composite(shell, SWT.NONE);
sidebar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1,
1));
sidebar.setBackground(SWTResourceManager.getColor(112, 128, 144));
sidebar.setLayout(new GridLayout(1, false));
ExpandBar expandBar = new ExpandBar(sidebar, SWT.NONE);
expandBar.setBackground(SWTResourceManager.getColor(112, 128, 144));
expandBar.setTouchEnabled(true);
GridData gd_expandBar = new GridData(SWT.CENTER, SWT.CENTER, false,
false, 1, 1);
gd_expandBar.heightHint = 619;
expandBar.setLayoutData(gd_expandBar);
ExpandItem xpndtmEmployeeDetails = new ExpandItem(expandBar, SWT.NONE,
0);
xpndtmEmployeeDetails.setExpanded(true);
xpndtmEmployeeDetails.setImage(SWTResourceManager.getImage(
Dashboard.class, "/resource/icons/employee.png"));
xpndtmEmployeeDetails.setText("Employee Details");
Composite expandbarComposite = new Composite(expandBar, SWT.NONE);
xpndtmEmployeeDetails.setControl(expandbarComposite);
xpndtmEmployeeDetails.setHeight(100);
expandbarComposite.setLayout(new FormLayout());
expandbarComposite.setBackground(SWTResourceManager
.getColor(SWT.COLOR_WIDGET_BACKGROUND));
Button btnAddNew = new Button(expandbarComposite, SWT.NONE);
btnAddNew.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/ic_add.png"));
FormData fd_btnAddNew = new FormData();
fd_btnAddNew.right = new FormAttachment(100, -10);
fd_btnAddNew.left = new FormAttachment(0, 38);
btnAddNew.setLayoutData(fd_btnAddNew);
btnAddNew.setText("Add New");
Button btnEdit = new Button(expandbarComposite, SWT.FLAT | SWT.CENTER);
btnEdit.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
}
});
btnEdit.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/edit.png"));
fd_btnAddNew.bottom = new FormAttachment(btnEdit, -6);
FormData fd_btnEdit = new FormData();
fd_btnEdit.left = new FormAttachment(btnAddNew, 0, SWT.LEFT);
fd_btnEdit.right = new FormAttachment(btnAddNew, 0, SWT.RIGHT);
fd_btnEdit.bottom = new FormAttachment(100);
btnEdit.setLayoutData(fd_btnEdit);
btnEdit.setText("Edit");
/**
* View Employees Button
* **/
Button btnViewEmployees = new Button(expandbarComposite, SWT.NONE);
btnViewEmployees.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
tabFolder.setSelection(empTab);
}
});
FormData fd_btnViewEmployees = new FormData();
fd_btnViewEmployees.right = new FormAttachment(btnAddNew, 0, SWT.RIGHT);
fd_btnViewEmployees.top = new FormAttachment(0, 6);
fd_btnViewEmployees.left = new FormAttachment(btnAddNew, 0, SWT.LEFT);
btnViewEmployees.setLayoutData(fd_btnViewEmployees);
btnViewEmployees.setText("View Employees");
ExpandItem xpndtmWorkSiteDetails = new ExpandItem(expandBar, SWT.NONE);
xpndtmWorkSiteDetails.setImage(SWTResourceManager.getImage(
Dashboard.class, "/resource/icons/worksite.png"));
xpndtmWorkSiteDetails.setText("Work Site Details");
Composite composite = new Composite(expandBar, SWT.NONE);
xpndtmWorkSiteDetails.setControl(composite);
xpndtmWorkSiteDetails.setHeight(100);
composite.setLayout(new FormLayout());
Button btnAddNew_1 = new Button(composite, SWT.NONE);
btnAddNew_1.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/ic_add.png"));
FormData fd_btnAddNew_1 = new FormData();
fd_btnAddNew_1.right = new FormAttachment(100, -10);
fd_btnAddNew_1.top = new FormAttachment(0, 37);
btnAddNew_1.setLayoutData(fd_btnAddNew_1);
btnAddNew_1.setText("Add New");
Button btnEdit_1 = new Button(composite, SWT.NONE);
fd_btnAddNew_1.bottom = new FormAttachment(btnEdit_1, -6);
fd_btnAddNew_1.left = new FormAttachment(btnEdit_1, 0, SWT.LEFT);
btnEdit_1.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/edit.png"));
FormData fd_btnEdit_1 = new FormData();
fd_btnEdit_1.left = new FormAttachment(0, 40);
fd_btnEdit_1.right = new FormAttachment(100, -10);
fd_btnEdit_1.bottom = new FormAttachment(100);
btnEdit_1.setLayoutData(fd_btnEdit_1);
btnEdit_1.setText("Edit");
Button btnViewWorks = new Button(composite, SWT.NONE);
FormData fd_btnViewWorks = new FormData();
fd_btnViewWorks.top = new FormAttachment(0, 6);
fd_btnViewWorks.left = new FormAttachment(btnAddNew_1, 0, SWT.LEFT);
fd_btnViewWorks.right = new FormAttachment(100, -10);
btnViewWorks.setLayoutData(fd_btnViewWorks);
btnViewWorks.setText("View Works");
ExpandItem xpndtmPaymentDetails = new ExpandItem(expandBar, SWT.NONE);
xpndtmPaymentDetails.setImage(SWTResourceManager.getImage(
Dashboard.class, "/resource/icons/payments.png"));
xpndtmPaymentDetails.setText("Payment Details");
Composite composite_1 = new Composite(expandBar, SWT.NONE);
xpndtmPaymentDetails.setControl(composite_1);
xpndtmPaymentDetails.setHeight(100);
composite_1.setLayout(new FormLayout());
Button btnAddNew_2 = new Button(composite_1, SWT.NONE);
btnAddNew_2.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/ic_add.png"));
FormData fd_btnAddNew_2 = new FormData();
fd_btnAddNew_2.left = new FormAttachment(0, 44);
btnAddNew_2.setLayoutData(fd_btnAddNew_2);
btnAddNew_2.setText("Add New");
Button btnEditPayments = new Button(composite_1, SWT.NONE);
fd_btnAddNew_2.bottom = new FormAttachment(btnEditPayments, -6);
fd_btnAddNew_2.right = new FormAttachment(btnEditPayments, 0, SWT.RIGHT);
btnEditPayments.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/edit.png"));
FormData fd_btnEditPayments = new FormData();
fd_btnEditPayments.left = new FormAttachment(0, 44);
fd_btnEditPayments.right = new FormAttachment(100, -10);
fd_btnEditPayments.bottom = new FormAttachment(100);
btnEditPayments.setLayoutData(fd_btnEditPayments);
btnEditPayments.setText("Edit Payments");
Button btnViewPayments = new Button(composite_1, SWT.NONE);
FormData fd_btnViewPayments = new FormData();
fd_btnViewPayments.right = new FormAttachment(btnAddNew_2, 0, SWT.RIGHT);
fd_btnViewPayments.top = new FormAttachment(0, 6);
fd_btnViewPayments.left = new FormAttachment(btnAddNew_2, 0, SWT.LEFT);
btnViewPayments.setLayoutData(fd_btnViewPayments);
btnViewPayments.setText("View Payments");
ExpandItem xpndtmOurTools = new ExpandItem(expandBar, SWT.NONE);
xpndtmOurTools.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/tools.png"));
xpndtmOurTools.setText("Tools Available");
Composite composite_3 = new Composite(expandBar, SWT.NONE);
xpndtmOurTools.setControl(composite_3);
xpndtmOurTools.setHeight(80);
composite_3.setLayout(new FormLayout());
Button btnViewTools = new Button(composite_3, SWT.NONE);
FormData fd_btnViewTools = new FormData();
fd_btnViewTools.top = new FormAttachment(0, 10);
fd_btnViewTools.right = new FormAttachment(100, -10);
fd_btnViewTools.left = new FormAttachment(100, -131);
btnViewTools.setLayoutData(fd_btnViewTools);
btnViewTools.setText("View Tools");
Button btnAddNew_3 = new Button(composite_3, SWT.NONE);
btnAddNew_3.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
System.out.println("Add tools");
}
});
FormData fd_btnAddNew_3 = new FormData();
fd_btnAddNew_3.right = new FormAttachment(btnViewTools, 0, SWT.RIGHT);
fd_btnAddNew_3.top = new FormAttachment(btnViewTools, 6);
fd_btnAddNew_3.left = new FormAttachment(btnViewTools, 0, SWT.LEFT);
btnAddNew_3.setLayoutData(fd_btnAddNew_3);
btnAddNew_3.setText("Add New");
ExpandItem xpndtmReports = new ExpandItem(expandBar, SWT.NONE);
xpndtmReports.setExpanded(true);
xpndtmReports.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/reports.png"));
xpndtmReports.setText("Reports");
xpndtmReports.setHeight(80);
Composite composite_2 = new Composite(expandBar, SWT.NONE);
xpndtmReports.setControl(composite_2);
composite_2.setLayout(new FormLayout());
Button btnGenerateReport = new Button(composite_2, SWT.NONE);
btnGenerateReport.setImage(SWTResourceManager.getImage(Dashboard.class,
"/resource/icons/gen_report.png"));
FormData fd_btnGenerateReport = new FormData();
fd_btnGenerateReport.top = new FormAttachment(0, 10);
fd_btnGenerateReport.left = new FormAttachment(0, 10);
fd_btnGenerateReport.right = new FormAttachment(100, -28);
btnGenerateReport.setLayoutData(fd_btnGenerateReport);
btnGenerateReport.setText("Generate Report");
xpndtmReports.setHeight(100);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
Can anyone suggest a solution. Thanks in advance.
And Finally I've figured the problem in the code. The composite in the base layout was assigned with the StackLayout as follows.
Composite content = new Composite(shell, SWT.BORDER);
content.setLayout(new StackLayout());
content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
When I changed the StackLayout to GridLayout, I got a working solution.
Composite content = new Composite(shell, SWT.BORDER);
content.setLayout(new GridLayout(1, false));
content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

Index was out of range. Must be non-negative and less than the size of the collection Error How to resolve?

Hi I am getting this error :
My code is like this, in the Reservationcontroller:
private void loadCountry()
{
ReservationHelper reservationHelperObject = new ReservationHelper();
ViewData["countryOut"] = new SelectList(reservationHelperObject.LoadCountry());
ViewData["countryIn"] = new SelectList(reservationHelperObject.LoadCountry());
CountryOut = ((MultiSelectList)(ViewData["CountryOut"])).ToList()[0].Text;
}
Any ideas ?
Continuation of code:
private void loadDefaultvalues()
{
List<string> emptyList = new List<string>();
ViewData["locationIn"] = new SelectList(emptyList);
ViewData["locationOut"] = new SelectList(emptyList);
ViewData["RateProgram"] = new SelectList(emptyList);
ViewData["Currency"] = new SelectList(emptyList);
ViewData["VehicleClass"] = new SelectList(emptyList);
ViewData["ReservationStatusDropDownList"] = new SelectList(emptyList);
ViewData["Miles"] = new SelectList(emptyList);
ViewData["currencyDropDownList"] = new SelectList(emptyList);
ViewData["ReservationStatus"] = new SelectList(emptyList);
ViewData["vehicleClassDropDownList"] = new SelectList(emptyList);
ViewData["rateProgramDropDownList"] = new SelectList(emptyList);
ViewData["parentOutDropDownList"] = new SelectList(emptyList);
ViewData["parentInDropDownList"] = new SelectList(emptyList);
ViewData["zoneOutDropDownList"] = new SelectList(emptyList);
ViewData["zoneInDropDownList"] = new SelectList(emptyList);
ViewData["locationOutDropDownList"] = new SelectList(emptyList);
ViewData["locationInDropDownList"] = new SelectList(emptyList);
ViewData["authorizationDropDownList"] = new SelectList(emptyList);
ViewData["specialServiceDropDownList"] = new SelectList(emptyList);
ViewData["RentalStatus"] = new SelectList(emptyList);
ViewData["Status"] = new SelectList(emptyList);
ViewData["Fop"] = new SelectList(emptyList);
ViewData["CustomerType"] = new SelectList(emptyList);
this.loadRentaStatus();
this.loadStatus();
this.loadFop();
this.loadCustomerTypes();
this.loadCountry();
this.loadReservationStatuses();
//this.loadMilesPercentage()
this.loadSpecialService();
this.loadRAType();
this.loadAirline();
this.loadTerminal();
this.loadParentCode();
this.loadZoneCode();
this.loadAuthorizationType();
}
Thanks
This code is evaluating to an empty list:
((MultiSelectList)(ViewData["CountryOut"])).ToList()
How to fix it? The best way is to do something like the following:
private void loadCountry()
{
ReservationHelper reservationHelperObject = new ReservationHelper();
ViewData["countryOut"] = new SelectList(reservationHelperObject.LoadCountry());
ViewData["countryIn"] = new SelectList(reservationHelperObject.LoadCountry());
var list = ((MultiSelectList)(ViewData["CountryOut"])).ToList();
if (list.Count > 0) {
CountryOut = list[0].Text;
} else {
// do something sensible when you have no data
}
}