Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Display label in center of Circle permanently #146

Open
markon1 opened this issue Feb 27, 2016 · 2 comments
Open

Display label in center of Circle permanently #146

markon1 opened this issue Feb 27, 2016 · 2 comments

Comments

@markon1
Copy link

markon1 commented Feb 27, 2016

I want to display an label always in center of circle. This is my code, but no label is being displayed, only circle.


var marker = L.circle([d.lat, d.long], radius,{color: "red", weight: 0,fillOpacity: opacity,fillColor:"red"}).bindLabel("label", { noHide: true }).addTo(map);
map.addLayer(marker);

I have included scripts like this:

<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<script type="text/javascript" src="js/leaflet.label.js"></script>
@kumarage
Copy link

@aybarska
Copy link

You need to include tooltip js first.
<script type="text/javascript" src="/path/to/leaflet-tooltip-layout.js"></script>

And if you want this to be always centered. You should add 'direction: center' to attirbutes. Like this:
circle.bindTooltip('label', {permanent: true, className: "durak_label",direction: 'center', offset: [0, 0] });

Check out here.
https://github.com/ZijingPeng/leaflet-tooltip-layout

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants