worthant / Java-labs

:ledger: Speedrun from 0 to Junior Java Developer
https://se.ifmo.ru/courses/programming
Other
7 stars 1 forks source link

Make Visualization [back+front] #79

Closed worthant closed 1 year ago

worthant commented 1 year ago
worthant commented 1 year ago

Guys, that is very sad, but unfortunately, webEngine do not support all the features, that i need to make this work. Placemarks from Yandex API just doesn't load and a lot of things fall apart.

Maybe, i will do the web stuff after that in 9th lab. For now, i will try to bypass this using custom icons, maybe it will still work.

1) how it shoud've look like (in the browser) 2) how i bypassed it because icons aren't showing up in webEngine

image_2023-06-01_01-53-01 image

worthant commented 1 year ago

Okay, i figured it out.

Generate icon name:

private String generateRandomIconName() {
    int iconNumber = new Random().nextInt(100) + 1;
    return "building_icon_" + iconNumber + ".svg";
}

Ans then, pass generated icon name to the js script:

function addCity(name, latitude, longitude, owner, iconName) {
    var placemark = new ymaps.Placemark([latitude, longitude], {
        hintContent: name,
        balloonContent: 'Owner: ' + owner
    }, {
        iconLayout: 'default#image',
        iconImageHref: '../icons/' + iconName,  // The path to the icon depends on how your project is structured
        iconImageSize: [15, 15],
        iconImageOffset: [-24, -24],
        iconContentLayout: MyIconContentLayout
    });

    myMap.geoObjects.add(placemark);
}
worthant commented 1 year ago

I have a new idea

worthant commented 1 year ago

I think the final version would look something like this:

image