yagajs / leaflet-ng2

Angular.io integration of Leaflet
https://leaflet-ng2.yagajs.org
ISC License
66 stars 26 forks source link

Icon tooltip initial position is incorrect. #378

Closed anna-khokhlova closed 6 years ago

anna-khokhlova commented 6 years ago

Hi all,

Icon tooltip initial position is incorrect - it is displayed lower than it should be. When I zoomed in and then zoomed out the tooltip position changed to correct one comparing to initial. HTMP template is:

<yaga-map>
   <yaga-zoom-control>
     <yaga-layers-control>
       <yaga-layer-group yaga-overlay-layer="Tag">
         <ul>
           <li>
             <yaga-marker [lat]="yPixel" [lng]="xPixel">
                <yaga-icon [iconUrl]="url" [iconSize]="size">
                    <yaga-tooltip [direction]="'right'" [permanent]="true" [offset]="tooltipOffset">{{label}} 
                    </yaga-tooltip>
                </yaga-icon>
             </yaga-marker>
           </li>
         </ul>
       </yaga-layer-group>
       <yaga-image-overlay>
       </yaga-image-overlay>
     </yaga-layers-control>
   </yaga-zoom-control>
 </yaga-map>

It looks like there is an issue with Tooltip's _container initialization. Initially its offsetHeight and offsetWidth are set incorrectly to [13,13] or [14,14] and its textContent is empty. These incorrect offsetHeight and offsetWidth are further used in _setPosition method to calculate the initail tooltip position. But after that the _container is initailized with the content and offsetHeight and offsetWidth changed and this caused correct further tooltip position calculation. I fixed the issue by moving the tooltip text to content accessor. But I think that the initial template should work correctly also.

Also there is a possible issue with map component crs initialization that can affect the tooltip position. Map's pixelOrigin is initailly set to [128,128] becasue L.CRS.Base scale function is used instead of configured map crs (simple CRS for my case).

Can you, please, fix this?

atd-schubert commented 6 years ago

I think this I think this is already solved by #377. Can you @anna-khokhlova check that?

anna-khokhlova commented 6 years ago

Can you, please, guide me how I can check it before official release?

atd-schubert commented 6 years ago

I think in your case maybe the easiest way is to just clone the git repo, run npm test and copy the contents of the lib folder to the one of leaflet-ng2 in your project modules directory.

For example: /path/to/your/project/node_modules/@yaga/leaflet-ng2/lib

anna-khokhlova commented 6 years ago

Hi atd-schubert, I will check it a bit later and will come back to you. Thank you for the instruction!

atd-schubert commented 6 years ago

I will close this issue. If you still have problems feel free to reopen this issue again...