gpt4 book ai didi

java - GeoTools:如何设置JMapFrame的显示范围(边界)

转载 作者:太空宇宙 更新时间:2023-11-04 06:32:43 26 4
gpt4 key购买 nike

我想在 JFrameMap 上设置显示范围

List<SimpleFeature> features = new ArrayList<SimpleFeature>();

GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();

Point point1 = gf.createPoint(new Coordinate(2,3));
Point point2 = gf.createPoint(new Coordinate(4,2));

SimpleFeatureBuilder fb = new SimpleFeatureBuilder(TYPE);

SimpleFeature f;

fb.add(point1);
fb.add("TP-1");

f = fb.buildFeature(null);
features.add(f);

fb.add(point2);
fb.add("TP-2");

f = fb.buildFeature(null);
features.add(f);

SimpleFeatureCollection collection = new ListFeatureCollection(TYPE,features);

Style style = createPointStyle();

Layer layer1 = new FeatureLayer(collection, style);

layer1.setTitle("TEST Map Layer");

MapContent map = new MapContent();
map.setTitle("Floor Map");
map.addLayer(layer1);

JMapFrame.showMap(map);

它显示我的点,但我不喜欢自动范围(边界)设置。问题是我该如何改变它?

最佳答案

您可以将视口(viewport)边界设置为您喜欢的任何内容:

 JMapFrame frame = new JMapFrame(map);
frame.getMapPane().getMapContent().getViewport().setBounds(envelope);

其中信封是ReferencedEnvelope。

关于java - GeoTools:如何设置JMapFrame的显示范围(边界),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25891831/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com