sothawo / mapjfx

JavaFX implementation of a map using OpenLayers and JavaFX
http://www.sothawo.com/projects/mapjfx/
Apache License 2.0
111 stars 29 forks source link

Did not opening WMS and getting error Slf4j #108

Open ezizrehimov opened 2 years ago

ezizrehimov commented 2 years ago

Hi. i am trying use MapJFX with WMS. Maybe i do something wrong , but i can't find, what i doing wrong.

I have this url: http://gis.marine-vts.site/geoserver/wms?version=1.1.0 Here is the layers list for the place: s57_7A100 s57_7A200 s57_7A300 s57_7A400 s57_7A402 s57_7A502 s57_7A602 s57_7A623

and example 1 layer : s57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb:s57.s57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb

i am tryed it in here: http://jsfiddle.net/tmoy0f0g/1/

var nexrad = L.tileLayer.wms("http://gis.marine-vts.site/geoserver/wms?version=1.1.0", { layers: 's57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb:s57.s57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb', format: 'image/png', transparent: true, attribution: "Weather data © 2012 IEM Nexrad" }).addTo(map); this is worked. but i need use it with MapJFX. i tryed like this.

package test1.test;

import com.sothawo.mapjfx.Configuration;
import com.sothawo.mapjfx.Coordinate;
import com.sothawo.mapjfx.MapType;
import com.sothawo.mapjfx.MapView;
import com.sothawo.mapjfx.Projection;
import com.sothawo.mapjfx.WMSParam;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class HelloApplication extends Application {

    private MapView mapView;
    private BorderPane m;
    private WMSParam wmsParam = new WMSParam()
            .setUrl("http://gis.marine-vts.site/geoserver/wms")
            .addParam("SERVICE", "WMS")
            .addParam("VERSION", "1.1.0")
            .addParam("REQUEST", "GetMap")
            .addParam("LAYERS", "s57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb:s57.s57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb")
            .addParam("FORMAT", "image/png");
    @Override
    public void start(Stage stage) {
        mapView = new MapView();
        mapView.minWidth(600);
        mapView.prefWidth(600);
        mapView.minHeight(600);
        mapView.prefWidth(600);

        final Projection projection = getParameters().getUnnamed().contains("wgs84")
                ? Projection.WGS_84 : Projection.WEB_MERCATOR;

        mapView.initializedProperty().addListener((observable, oldValue, newValue) -> {
            if (newValue) {
                mapView.setZoom(13);
                mapView.setCenter(new Coordinate(40.741895, -73.989308));
            }
        });
        mapView.setWMSParam(wmsParam);
        mapView.setMapType(MapType.WMS);

        mapView.initialize(Configuration.builder()
                .projection(projection)
                .showZoomControls(false)
                .build());

        m = new BorderPane();
        m.setCenter(mapView);

        Scene scene = new Scene(m, 600, 600);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

i added in pom.xml 2.15.1 `

com.sothawo mapjfx 2.15.1

` Getting this error:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Java Version 15

sothawo commented 2 years ago

The slf4j messages you see mean that you do not have a logging library implementation on your classpath with an appropriate configuration.

As for the WMS server: When I use the test program from the mapjfx program and activate the online cache (in order to see the requested URLs in the logs) I see that the URLs that are loaded have this form:

http://gis.marine-vts.site/geoserver/wms?SERVICE=WMS&VERSION=1.1.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=s57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb%3As57.s57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb&WIDTH=256&HEIGHT=256&SRS=EPSG%3A3857&STYLES=&BBOX=931920.2488528676%2C6276397.266552392%2C934366.2337579933%2C6278843.251457518

If you load these - no matter which of the many I try - I get an empty transparent tile. If I use a different WMS configuration, I get a link like https://ows.terrestris.de/osm/service?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&layers=OSM-WMS&WIDTH=256&HEIGHT=256&CRS=EPSG%3A3857&STYLES=&BBOX=927028.2790426165%2C6276397.266552392%2C929474.2639477422%2C6278843.251457518 which is a tile containing a map image.

The linked JSFiddle: this displays nothing for me image

ezizrehimov commented 2 years ago

sorry i forgot added lat & lon. Please try like that in JSFiddle:

var map = L.map('map', {
    center: [39.78, 50.30],
    zoom: 9
});

var nexrad = L.tileLayer.wms("http://gis.marine-vts.site/geoserver/wms?version=1.1.0", { layers: 's57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb:s57.s57_7A100__08415007-22d4-4aa6-8622-20fbce0008cb', format: 'image/png', transparent: true, attribution: "Weather data © 2012 IEM Nexrad" }).addTo(map);

image

sothawo commented 2 years ago

sorry, I have no time to experiment with JSFiddle. The link that are produced for your WMS configuration return transparent images, so there must be an error in that configuration.