Select to view content in your preferred language

Issue while drawing a custom HTML label on map panning

532
1
03-13-2023 03:58 AM
ManasDas
New Contributor II

Hi Team,

I have a feature requirement where I need to draw and point and then a second point and a curved great circle line connecting the 2 points on the map. The second point needs to have a label. The label here is a normal HTML label which is being drawn outside the esri map[the label moves with the second point]. I can generally show[with minor offset] the label using the lat-long of my second point. I normally use the 'drag'  , 'hover' and 'click' events and all the events give the exact screen coordinates [the actual device screen coordinates[clientX and clientY] and not esri map (toScreen)]. So all works fine while drawing the 2 points and the great circle line. Once the second point is drawn, all the graphic objects (+ HTML label)stay fixed.

 

The issue -

Once the 2 points and the great circle line is drawn, the user can pan the map to any part of the world. When I come back to the same lat-long[by dragging/goTo()] where my 2 points and great circle line was drawn , the screen point value changes [using the toScreen method]. I am guessing the reason is that the user can come to that same point by moving clock-wise or anti-clock wise[dragging] over the full map view. Due to the extreme panning of the map, the top left of the view changes and this changes the result of the toScreen.

Note: When I initially draw the graphics, my toScreen returns X value of around 700, but after panning the map, the toScreen returns around 8000+. If I convert this[8000+] screen coordinate value to lat-long [using toMap], I get the correct lat-long again. Obviously I can show a label at around 700px on my screen, but I cannot show a label at 8000px.

Is there any way I can convert this 8000 screen point value back to my 700px clientX value?

 

Is there any other approach of doing this?

0 Kudos
1 Reply
ManasDas
New Contributor II

Strange!! I implemented the arcGIS popup and observed the same issue. Do you convert the long-lat of the 'location' field to ScreenPoint using toScreen?

0 Kudos