sothawo / mapjfx

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

Marker custom marker image #100

Closed lanthale closed 3 years ago

lanthale commented 3 years ago

Thank you for the good component. I am under way to use your component in my app Photoslide (https://github.com/lanthale/photoslide). There is one issue I am facing with: There is no possability to specify a node as a marker. Instat I have always to provide an URL for an image. It would be realy helpful if you can add an Image class beside the URL because than I can also create in memory an image based on a FontIcon (project ikonli). The reason the build in types are not feasible is that in higher zoom levels they are very big and that looks not so good for my application.

I would appreciate if you can extend the lib to include such a function.

sothawo commented 3 years ago

The marker images are not rendered by Java code. The MapView component is basically just a browser ( a WebView) that loads a minimal HTML page loading the map stuff from OpenLayers. So all this map displaying, markers, lines are done in Javascript in a webpage context.

Do you have the possiblity to write your generated image to a ByteArrayOutputStream for example in png format? You could then create a data URI with

ByteArrayOutputStream os = new ByteArrayOutputStream();
// write data to os
String contentType = "image/png";
URI dataUri = new URI("data:" + contentType + ";base64," +
    Base64.getEncoder().encodeToString(os.toByteArray()));

You could then use pass dataUri to the marker.

lanthale commented 3 years ago

Thanks that helps allot.