gluonhq / maps

https://gluonhq.com/labs/maps/
GNU General Public License v3.0
140 stars 36 forks source link

Desktop issues #25

Closed Gustafsonde closed 3 years ago

Gustafsonde commented 5 years ago

The sample code works in a Desktop application. But if I change it slightly to

        if (Platform.isDesktop()) {
//            scene = new Scene(view, 600, 700);
            AnchorPane ap = new AnchorPane(view);
            scene = new Scene(ap, 600, 700);
            stage.setTitle("Gluon Maps Demo");
        } else {

then it does not work--the mouse can't be used to drag in the y axis and zooming out by scrolling does not work (zoom-in does work). flyTo() does not work as expected and the map is initially displayed at x,y coordinates 0,0.

I suppressed the problems by making the BaseMap.moveY() method work symmetrically to the BaseMap.moveX(), and by changing the BaseMap.getMyWidth() and BaseMap.getMyHeight() to use getBoundsInParent() but I doubt if either of these does anything other than mask the symptoms.

jperedadnr commented 5 years ago

The AnchorPane or the Group container don't apply any constraint to the MapView layout, so it will expand to its default size of 2048x2048 (given by its 8x8 tiles of 256x256), regardless of the scene size.

On the contrary, it will work fine if you use a StackPane, though, as it will constrain the map to the scene size.

A possible solution for the AnchorPane will be setting these anchors:

AnchorPane.setBottomAnchor(view, 0d);
AnchorPane.setTopAnchor(view, 0d);
AnchorPane.setLeftAnchor(view, 0d);
AnchorPane.setRightAnchor(view, 0d);