我试图使用传单库在图像上绘制标记,我面临的问题如下:
Leaflet从左下角绘制x,y坐标,而我从服务中获得的坐标绘制坐标,假设轴在左上角。
var pixelsPerUnit = site.siteImageHeightinPX / site.height;
for (var i = 0; i < ap.length; i++) {
var x = ap[i].xPos * pixelsPerUnit;
var y = ap[i].yPos * pixelsPerUnit;
console.log(x+" "+y);
var m = L.marker(xy(x,y), {icon: apIcon});
markers.addLayer(m);
}
JSON
{
"site": {
"width": 308.44,
"height": 205.63,
"siteImageWidthinPX": 3456,
"siteImageHeightinPX": 2304,
"testPoints": [
{
"testPointID": "1712",
"xPos": 44.366,
"yPos": 52.114
},
{
"testPointID": "1701",
"xPos": 94.87,
"yPos": 54.276
}
]
}
}