I want to add a text to the map that not scaled when zoom change and remain with it's original sizes.
I use this code (javascript):
var text = new L.marker(rect.getBounds().getSouthWest(), {opacity: 0.0001});
text.bindLabel("TEXT", styleProperties);
text.addTo(myLayer);
and obtain this unwanted result:
I want that the text remain with the sizes of the first image at left when zoom are applied. Is it possible?
edit: the text must be like a name of the city, that moves with map but not change it's size when zoom (yes, I know that name of cities are images, for that not is easy solve my problem). Thanks however for answers, for now I maintain the labes, not is an elegant solution but works.
Adding a Simple MarkerStep 1 − Create a Map object by passing a <div> element (String or object) and map options (optional). Step 2 − Create a Layer object by passing the URL of the desired tile. Step 3 − Add the layer object to the map using the addLayer() method of the Map class.
Is there a fee for using it? Leaflet, unlike Google Maps and other all-in-one solutions, is just a JavaScript library. It's free to use, but doesn't provide map imagery on its own — you have to choose a tile service to combine with it.
Leaflet is designed with simplicity, performance and usability in mind. It works efficiently across all major desktop and mobile platforms, can be extended with lots of plugins, has a beautiful, easy to use and well-documented API and a simple, readable source code that is a joy to contribute to.
You could use Leaflet.label plugin (starting with Leaflet 1.0, L.Label is added to Leaflet core as L.Tooltip). You can style it with your own css. See the example.
It looks to me your text is not really related to your map. What about adding the text in another div over the container of the map ?
<div>
<div id="map" style="width: 600px; height: 400px"></div>
<div style="pointer-events: none; position: absolute; top: 100px; left: 100px">foo bar</div>
</div>
See full example here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With