OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

here map: snapshot api screenshots not showing any markers

  • Thread starter Thread starter Deniss M.
  • Start date Start date
D

Deniss M.

Guest
I am trying to use the snapshot API via HERE Maps JS to take a screenshot of the current map. The screenshot only shows the map without any markers (a mixture of html + img which contains an SVG).

This is the code for adding markers:

Code:
...
const markerElement = document.createElement('div');
markerElement.id = m.report.extId;
markerElement.className = 'marker-item';
markerElement.style.animation = `fadeIn ease ${animationSpeed}`;
markerElement.style.height = `${this.iconSize}px`;
markerElement.style.width = `${this.iconSize}px`;
markerElement.style.position = 'absolute';
markerElement.style.left = '-25px';
markerElement.style.zIndex = '1';
const fragment = document.createDocumentFragment();

...

const mainIcon = document.createElement('IMG');
mainIcon.setAttribute('src', m.icon);
mainIcon.id = m.report.extId;
mainIcon.className = 'marker-item';
mainIcon.style.width = `${this.iconSize}px`;
mainIcon.style.height = `${this.iconSize}px`;
mainIcon.style.zIndex = '1';
fragment.appendChild(mainIcon);

...

markerElement.appendChild(fragment);
const icon = new H.map.DomIcon(markerElement);
const coords = {lat: +m.lat, lng: +m.long};
const marker = new H.map.DomMarker(coords, {icon});

this.map.addObject(marker);
...

What is also interesting is that I have another "type" of marker, which actually is visible on the screenshot:

Code:
const presenceElement = document.createElement('div');
presenceElement.id = p.extId;
presenceElement.className = 'presence-item';
presenceElement.style.animation = `fadeIn ease ${animationSpeed}`;
presenceElement.style.height = `${this.iconSize / 3}px`;
presenceElement.style.width = `${this.iconSize / 3}px`;
presenceElement.style.position = 'absolute';
presenceElement.style.background = 'green';
presenceElement.style.borderRadius = '20px';
presenceElement.style.opacity = '0.1';
presenceElement.style.border = '1px solid white';
presenceElement.style.left = '-15px';
presenceElement.style.zIndex = '1';

const icon = new H.map.DomIcon(presenceElement);
const coords = {lat: +p.lat, lng: +p.lng};
const marker = new H.map.DomMarker(coords, {icon});

this.map.addObject(marker);

I am wondering if anybody had the same issue and was able to solve it.

<p>I am trying to use the snapshot API via HERE Maps JS to take a screenshot of the current map. The screenshot only shows the map without any markers (a mixture of html + img which contains an SVG).</p>
<p>This is the code for adding markers:</p>
<pre><code>...
const markerElement = document.createElement('div');
markerElement.id = m.report.extId;
markerElement.className = 'marker-item';
markerElement.style.animation = `fadeIn ease ${animationSpeed}`;
markerElement.style.height = `${this.iconSize}px`;
markerElement.style.width = `${this.iconSize}px`;
markerElement.style.position = 'absolute';
markerElement.style.left = '-25px';
markerElement.style.zIndex = '1';
const fragment = document.createDocumentFragment();

...

const mainIcon = document.createElement('IMG');
mainIcon.setAttribute('src', m.icon);
mainIcon.id = m.report.extId;
mainIcon.className = 'marker-item';
mainIcon.style.width = `${this.iconSize}px`;
mainIcon.style.height = `${this.iconSize}px`;
mainIcon.style.zIndex = '1';
fragment.appendChild(mainIcon);

...

markerElement.appendChild(fragment);
const icon = new H.map.DomIcon(markerElement);
const coords = {lat: +m.lat, lng: +m.long};
const marker = new H.map.DomMarker(coords, {icon});

this.map.addObject(marker);
...

</code></pre>
<p>What is also interesting is that I have another "type" of marker, which actually is visible on the screenshot:</p>
<pre><code>const presenceElement = document.createElement('div');
presenceElement.id = p.extId;
presenceElement.className = 'presence-item';
presenceElement.style.animation = `fadeIn ease ${animationSpeed}`;
presenceElement.style.height = `${this.iconSize / 3}px`;
presenceElement.style.width = `${this.iconSize / 3}px`;
presenceElement.style.position = 'absolute';
presenceElement.style.background = 'green';
presenceElement.style.borderRadius = '20px';
presenceElement.style.opacity = '0.1';
presenceElement.style.border = '1px solid white';
presenceElement.style.left = '-15px';
presenceElement.style.zIndex = '1';

const icon = new H.map.DomIcon(presenceElement);
const coords = {lat: +p.lat, lng: +p.lng};
const marker = new H.map.DomMarker(coords, {icon});

this.map.addObject(marker);

</code></pre>
<p>I am wondering if anybody had the same issue and was able to solve it.</p>
 

Latest posts

Top