Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getScreenCoordinate returns wrong points #33

Open
kutoman opened this issue Dec 12, 2018 · 0 comments
Open

getScreenCoordinate returns wrong points #33

kutoman opened this issue Dec 12, 2018 · 0 comments

Comments

@kutoman
Copy link
Contributor

kutoman commented Dec 12, 2018

When a marker is placed at the left border of a map which is the left border of the screen at the same time I would expect that getScreenCoordinate(myMarker) returns a point with x == 0 (or near 0) but I for example get 160 at the state demonstrated at the snapshot below (the marker image is just 50 pixel wide). The issue is similar for the y axis.
This wasn't the case a while ago.

bildschirmfoto 2018-12-12 um 12 14 07

sample code:

    final String API_KEY = "key";

    final MapContainer mapContainer = new MapContainer(API_KEY);
    
    Form f = new Form("Maps", new LayeredLayout());
    f.setScrollable(false);
    f.add(mapContainer);

    
    Coord originalC = new Coord(50.96280565137735, 7.047107219696045);
    
    EncodedImage ei = EncodedImage.createFromImage(
            FontImage.createMaterial(FontImage.MATERIAL_GPS_FIXED, f.getUnselectedStyle())
            , false);

    MapContainer.MarkerOptions mo = new MapContainer.MarkerOptions(originalC, ei)
    .anchor(0.5f, 0.5f)
    .onClick((evt) -> {
        log.p("clicked on marker" + originalC);
    });

    MapContainer.MapObject obj = mapContainer.addMarker(mo);

    f.getToolbar().addCommandToRightBar("", FontImage.createMaterial(FontImage.MATERIAL_ADD_CIRCLE, f.getUnselectedStyle()), (ev) -> {
        System.out.println("PRINTOUT:");
        System.out.println("Point of Marker: " + mapContainer.getScreenCoordinate(originalC));
        System.out.println("Screen: " + CN.getDisplayWidth() + "x" + CN.getDisplayHeight());
        System.out.println("MapC: " + mapContainer.getWidth() + "x" + mapContainer.getHeight());
        
        
    });
    
    f.getToolbar().addCommandToRightBar("", FontImage.createMaterial(FontImage.MATERIAL_ZOOM_IN, f.getUnselectedStyle()), (ev) -> {
        System.out.println("focus");
        mapContainer.zoom(originalC, (int) mapContainer.getZoom());
    });
    
    mapContainer.zoom(originalC, 10);
    f.revalidate();
    
    f.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant