Added get map size (width and height) method in canvasMap with given boundary

#story[928]
This commit is contained in:
Haoming Yin
2017-05-15 17:06:28 +12:00
parent 4b1a4aae87
commit eda3d76077
@@ -13,7 +13,6 @@ public class CanvasMap {
private double width, height; // desired image size private double width, height; // desired image size
private int zoom; private int zoom;
private int MERCATOR_RANGE = 256;
private String KEY = "AIzaSyC-5oOShMCY5Oy_9L7guYMPUPFHDMr37wE"; private String KEY = "AIzaSyC-5oOShMCY5Oy_9L7guYMPUPFHDMr37wE";
public CanvasMap(Boundary bound, double width, double height) { public CanvasMap(Boundary bound, double width, double height) {
@@ -46,4 +45,23 @@ public class CanvasMap {
// sb.append(String.format("&key=%s", KEY)); // sb.append(String.format("&key=%s", KEY));
return sb.toString(); return sb.toString();
} }
private MapSize getMapSize(int zoom, Boundary boundary) {
double scale = Math.pow(2, zoom);
MapGeo geoSW = new MapGeo(boundary.getSouthLat(), boundary.getWestLng());
MapGeo geoNE = new MapGeo(boundary.getNorthLat(), boundary.getEastLng());
MapPoint pointSW = MercatorProjection.toMapPoint(geoSW);
MapPoint pointNE = MercatorProjection.toMapPoint(geoNE);
return new MapSize(Math.abs(pointNE.getX() - pointSW.getX()),
Math.abs(pointNE.getY() - pointSW.getY()));
}
class MapSize {
long width, height;
MapSize(double width, double height) {
this.width = (long) width;
this.height = (long) height;
}
}
} }