Wednesday, 24 November 2021

Openlayers making map with images

I would like to be able to upload the images to any place in the map and display them as a thumbnail.

So far I've managed with uploading the image to the server. Unfortunately, it's only one image, which I can put and it goes just underneath my map.

I used the following code:

https://www.codegrepper.com/code-examples/javascript/display+image+upload+javascript

and my code looks like this:

/* IMAGE UPLOAD */
 var loadFile = function(event) {
 var output = document.getElementById('output');
 output.src = URL.createObjectURL(event.target.files[0]);
 output.onload = function() {
 URL.revokeObjectURL(output.src) // free memory
 }
};

which can be found in the web below:

http://mlearnweb.online/

There is quite a few libraries in the web, which allow us to upload images to the web, but at the same basis as presented in my case.

I need something like formerly for Panoramio.com. The similar thread I found here;

Adding Panoramio Photos To An OpenLayers Map

but as we know Panoramio.com doesn't exist anymore.

I need something like this:

enter image description here

Is it possible with OpenLayers map?

UPDATE:

With this example:

http://eap.ucr.ac.cr/mapas/ol-ext-master/examples/map/map.dbpedia.photo.html

I could extract the relevant code:

 select.getFeatures().on(['add','remove'], function(e){
   var info = $("#select").html("");
  if (e.type=="add") {
   var el = e.element.get("features")[0];
   $("<h2>").text(el.get("label")).appendTo(info);
   if (el.get("thumbnail")) $(" 
    <img>").attr('src',el.get("thumbnail")).appendTo(info);
   $("<p>").text(el.get("abstract")).appendTo(info);
   }

but I am getting an error:

Unexpected end of input

The link to the full code is here:

https://mlearnweb.online/



from Openlayers making map with images

No comments:

Post a Comment