[英]How do you move an envelope to a specific point?
Point p = /*a point*/;
ReferencedEnvelope envelope = mapPane.getDisplayArea();
/*envelope.moveTo or something like that? */
mapPane.setDisplayArea(envelope);
How can I move the envelope so that the center position is the position of the given point?如何移动信封,使中心位置是给定点的位置? All I see are "expand"-methods.我所看到的只是“扩展”方法。
The easiest way is to create a new envelope centred on your new point:最简单的方法是创建一个以新点为中心的新信封:
ReferencedEnvelope env = fr.getMapPane().getDisplayArea();
double x,y;//new centre
double w2 = env.getWidth()/2.0;
double h2 = env.getHeight()/2.0;
Coordinate c = new Coordinate(x,y);
ReferencedEnvelope renv = new ReferencedEnvelope(c.x-w2,c.x+w2,c.y-h2,c.y+h2,env.getCoordinateReferenceSystem());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.