Leaflet / Leaflet.label

Leaflet.label is plugin for adding labels to markers & shapes on leaflet powered maps.
MIT License
465 stars 225 forks source link

The label is not always in the same position when zooming #125

Closed ayasha88 closed 9 years ago

ayasha88 commented 9 years ago

I have a problem with the labels binded to some markers when zooming in and out. In the following pictures you can see an example of the problem:

cattura cattura2 cattura3 cattura4

As you can see when I zoom in the label is always closer to my marker. The problem is that I always want it to be as the last picture, that is simply under my marker.

Here is my code:

  var myPos = new L.latLng(lat, lon); //lat and lon are coordinates defined above 
  var markerMyPos = L.marker(myPos, {
      icon: myIcon
  }); 
  markerMyPos.bindLabel('Some text', { noHide: true, className: 'marker_label', direction: 'right', offset: [-70, 0] }).addTo(map);

This happens mostly when I am at a low level of zoom and go down fast, instead if I am already at a high level of zoom and zoom more then the labels are nearer to the marker...

MattSidor commented 9 years ago

It might have something to do with your 'marker_label' class, or there might be something else in your Javascript code that is transforming the DOM / altering the label's anchor point on zoom events.

Can you replicate this example in a JSFiddle / Plunker for us?

Also, can you clarify what you mean by your last sentence? I'm not totally sure I follow you. Does the behavior change based on your starting zoom level?

ayasha88 commented 9 years ago

Oh I think I resolved.. I forgot to add the leaflet.label.css file.. Thanks!

MattSidor commented 9 years ago

Glad to hear it. Can you close this issue for us? Thanks!