GMapsFX
GMapsFX copied to clipboard
How can i display images on infoWindowOptions
Very good job of this API
They could help me place Images in an infoWindowsOption, since I need to display images for each marker on the Map.
Thank you so much.
The content of the InfoWindow can be set via the content() call on the InfoWindowOptions or on the InfoWindow itself using setContent(). This is HTML, and is run in the context of the web page, within the WebView. This is going to have the typically limitations we've found with referencing marker images in jars etc. WebView expects images to be available in a web fashion rather than a java jar fashion, it has no idea about jars etc.
The web page it's running is in the GMapsFX jar, so it wont be able to directly reference any images you might have in other jars or on your local filesystem. You can get it to run your own web page in your own jar, in which case you'd be able to use references relative to the location of the html file in the jar's folder structure, but this ends up being more complicated.
Options for using the GMapsFX supplied html page include:
Use external images available via a fully qualified URL:
<img src="http://sample.domain.com/images/myimage.jpg" />
Use the new MarkerImageFactory to create the image source as a data URI, though this does appear to have some limitations on some platforms. I've gotten it to work, YMMV! It also wont load off the local filesystem yet, the images need to be packaged in a jar on the classpath.
String infoImg = MarkerImageFactory.createMarkerImage("/my/gmapsfx/sample/res/Flower.png", "png");
InfoWindowOptions infoOptions = new InfoWindowOptions();
infoOptions.content("<h2>Here's an info window</h2><p>with some info and a picture</p><p><img src=\"" + infoImg + "\" /></p>").position(centre);
InfoWindow window = new InfoWindow(infoOptions);
window.open(map, myMarker);
This assumes an image called Flower.png in /my/gmapsfx/sample/res/ of my jar file. I've committed a quick sample that illustrates the MarkerImageFactory usage at: https://github.com/GeoffCapper/GMapsFXSample
Thank you so much
Ya he podido hacer que se vean las imagenes de acurdo con tu pronta respuesta