При добавлении слоев на карту экран компьютера мигает - PullRequest
0 голосов
/ 10 мая 2019

Я добавляю 1 точку на карту, добавляя точку к слою, а затем добавляю слой на карту. Я так и сделал, и время, когда я добавил слой экрана, моргнуло, попросив всех не моргнуть

Я использую Java 8 + Geotools

private void addClickPoint(MapMouseEvent ev){ 
        DirectPosition2D pos = ev.getMapPosition();
        double x = pos.x;
        double y = pos.y;

        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        builder.setName("MyFeatureType");
        builder.setCRS(DefaultGeographicCRS.WGS84); // set crs
        builder.add("location", MultiPoint.class); // add geometry

        // build the type
        SimpleFeatureType TYPE = builder.buildFeatureType();
        // create features using the type defined
        SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE);

        // ===> Tạo ra 1 point khi click
        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
        Coordinate coord = new Coordinate(x, y);
        Point point = geometryFactory.createPoint(coord);

        DefaultFeatureCollection featureCollection = new 
        DefaultFeatureCollection();
        featureBuilder.add(point);
        SimpleFeature feature = featureBuilder.buildFeature("FeaturePoint");
        featureCollection.add(feature); // Add feature 1, 2, 3, etc

        Style style = SLD.createPointStyle("circle", Color.BLUE, Color.BLUE, 0.3f, 15);
        Layer layer = new FeatureLayer(featureCollection, style);

        layer.setTitle("Click Point");
        map.layers().add(layer);
}

Я хочу, чтобы экран не мигал

...