0

I am upgrading here maps to version 3.1, trying draw a draggable polygon. I have replaced a few methods and now working on replacing H.geo.strip() with H.geo.lineString(). However, When I try to insert 1st point into the line string in like this -

_this.growingStrip = new H.geo.LineString();
_this.growingStrip.pushPoint(_this.map.screenToGeo(e.currentPointer.viewportX, e.currentPointer.viewportY));

Here is what gets pushed in _this.growingStrip -

{
"X":[]
,"a":0
}

But it was different when I was using H.geo.strip() as follow -

_this.growingStrip = new H.geo.Strip();
_this.growingStrip.pushPoint(_this.map.screenToGeo(e.currentPointer.viewportX, e.currentPointer.viewportY));

This was pushing a following object -

{"a":null,"b":[63.628684238260696,55.35862348973751,0,53.22838240102656,70.12424848973751,0],"c":0}

I have really tried hard to wrap my head around it but no luck. Any help is appreciated. TIA

1 Answers1

0

I tried with code similar to yours and all works fine. Points are pushed to the LineString correctly after each click:

var growingStrip = new H.geo.LineString();

map.addEventListener('tap', (e) => {
  let cp = e.currentPointer;
  growingStrip.pushPoint(map.screenToGeo(cp.viewportX, cp.viewportY));
  console.log(growingStrip.getLatLngAltArray());
})

// after first click -> (3) [36.11458078918906, 8.356475830078125, 0]
// after second click -> (6) [36.11458078918906, 8.356475830078125, 0, -6.58685279251426, 0.1263427734375, 0]
// ...
Tomas
  • 1,849
  • 1
  • 13
  • 13