Skip to content

Map latLngToContainerPoint method #474

@jacobtoye

Description

@jacobtoye

I am trying to convert a lat lng to the screen relative pixel position. I assume that map method latLngLayerPoint would do this. For the initial load it would be perfect, however after panning the map the returned Point does not change. I would expect this to change by the offset.

Am I using this method for the wrong purpose?

Looking into the code it seems that latLngLayerPoint is using _initialTopLeftPoint.. This variable is only updated when the view is reset.

I also notice that _getTopLeftPoint (line 600) is subtracting the map pane's offset. Should latLngLayerPoint be updated to also subtract the same offset?

At the moment I am using:

map.project(new L.LatLng(lat, lng)).round().subtract(map._getTopLeftPoint());

I would prefer to use one of the public methods.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions