Reputation: 5923
I'm using mapbox.js to create a voronoi map. However, I'm having issues with the accuracy of my projections from the latitude/longitude to the pixels on my screen as the accuracy is only int instead of float. This causes the points to change slightly when zooming in/out, causing the overall voronoi map to change!
Edit: I've updated the code to also include the code that generates the voronoi. You can see that the voronoi code uses the pixels, which is thus problematic as the accuracy can be problematic.
var voronoi = d3.geom.voronoi()
.x(function (d) {
return d.x;
})
.y(function (d) {
return d.y;
});
filteredPoints.forEach(function (d) {
var latlng = new L.LatLng(d.latitude, d.longitude);
var point = map.latLngToLayerPoint(latlng);
d.x = point.x;
d.y = point.y;
}
voronoi(filteredPoints).forEach(function (d) {
d.point.cell = d;
});
Upvotes: 1
Views: 217
Reputation: 11882
Read the Leaflet source and write the same thing, except without the call to round()
Upvotes: 1