1
BING Maps API를 사용하여지도에 막대 차트를 만듭니다. char에 일부 다각형이 있지만 컬렉션에 이벤트 핸들러를 추가 할 수없고 폴리곤에 추가하는 모든 이벤트가 즉시 발생합니다. bing 맵에 이벤트 처리기를 추가하는 방법 EntityCollection?
var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials:"CREDENTIALS",
mapTypeId: Microsoft.Maps.MapTypeId.road,
zoom: 13,
center: new Microsoft.Maps.Location(51.363247,12.467959)});
var center = map.getCenter();
var chart = drawBarChart(map.getCenter(),10,20,30, 0.005);
map.entities.push(chart);
...
function drawBarChart(location, value1, value2, value3, zoom) {
var chart = new Microsoft.Maps.EntityCollection();
var sum = value1 + value2 + value3;
var height1 = value1/sum * zoom;
var maxHeight = Math.max(height1, height2, height3) + 0.1 * zoom;
var rectPoints = new Array(5)
rectPoints[0] = new Microsoft.Maps.Location(location.latitude - 0.1 * zoom, location.longitude - 0.1 * zoom);
rectPoints[1] = new Microsoft.Maps.Location(location.latitude - 0.1 * zoom, location.longitude + 0.7 * zoom);
rectPoints[2] = new Microsoft.Maps.Location(location.latitude + maxHeight, location.longitude + 0.7 * zoom);
rectPoints[3] = new Microsoft.Maps.Location(location.latitude + maxHeight, location.longitude - 0.1 * zoom);
rectPoints[4] = new Microsoft.Maps.Location(location.latitude - 0.1 * zoom, location.longitude - 0.1 * zoom);
var black = new Microsoft.Maps.Color(200, 50, 50, 50);
var white = new Microsoft.Maps.Color(200, 255, 255, 255);
var transparent = new Microsoft.Maps.Color(0, 255, 255, 255);
var border = new Microsoft.Maps.Polygon(rectPoints, {
strokeColor: transparent,
fillColor: white
});
chart.push(border);
Microsoft.Maps.Events.addHandler(chart , 'mouseover', displayEventInfo);
return chart;
문제점은 무엇입니까?