Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Technical Evangelist
Posts: 1,163
Registered: ‎09-11-2015
Accepted Solution

Placing text watermark / copyright on Portal map

Has anyone tried to place a text watermark, similar to "OpenStreetMap Constributors" link in the bottom right corner? We're trying to simply inject similar code after that OSM <div> element like this:

 

document.addEventListener('DOMContentLoaded', function() {
   console.log('DOMContentLoaded event');
var mapDiv = document.getElementsByClassName("wc_map_layer")[0];
console.log(mapdiv); mapDiv.innerHTML += '<div style="bottom:55px; position: fixed; right: 0;">' + '<a href="https://pasvaldiba.riga.lv/EN/Channels/About_Riga/default.htm" target="_blank">Riga City</a>' + '</div>'; })

It works well if I do it through developer console:

Untitled.png

 

But it doesn't work when this script is loaded on run-time. I can see the DOMContentLoaded entry in the log and mapDiv content is also ok. But still no hyperlink gets rendered.

 

Any help would be appreciated.

 

Thanks,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Technical Evangelist
Posts: 1,163
Registered: ‎09-11-2015

Re: Placing text watermark / copyright on Portal map

[ Edited ]

Ok, got it working with this code:

 

document.addEventListener('DOMContentLoaded', function () {
   var mapControls = document.getElementsByClassName("wc_map");
   for (var i = 0; i < mapControls.length; i++) {
      if (mapControls[i].id.indexOf('WCMapControl') !== -1) {
         var div = document.createElement('div');
         div.style.bottom = '55px';
         div.style.fontFamily = 'Verdana';
         div.style.fontSize = '8pt';
         div.style.padding = '2px';
         div.style.backgroundColor = 'rgba(240,240,240,0.9)';
         div.style.position = 'fixed';
         div.style.right = '5px';
         div.innerHTML = '<a href="https://pasvaldiba.riga.lv/EN/Channels/About_Riga/default.htm" target="_blank">Riga City</a>';
         mapControls[i].appendChild(div);
      }
   }
});

I had to expand the DIV element definition to be correctly embedded in the parent DIV.

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial