example = () => {
	const myIcon = L.icon({
		iconUrl: 'my-icon.png',
		iconSize: L.point(20, 20),
		iconAnchor: L.point(10, 10),
		labelAnchor: L.point(6, 0) // as I want the label to appear 2px past the icon (10 + 2 - 6)
	});
	L.marker(L.latLng(-37.7772, 175.2606), {
		icon: myIcon
	}).bindLabel('Look revealing label!').addTo(map);
};
example = () => {
	const myIcon = L.icon({
		iconUrl: 'my-icon.png',
		iconSize: L.point(20, 20),
		iconAnchor: L.point(10, 10),
		labelAnchor: L.point(6, 0) // as I want the label to appear 2px past the icon (10 + 2 - 6)
	});
	L.marker(L.latLng(-37.7772, 175.2606), {
		icon: myIcon
	}).bindLabel('My label', {
		noHide: true,
		direction: 'auto'
	});
};
Пример #3
0
let latLngBounds: L.LatLngBounds;
latLngBounds = L.latLngBounds(latLng, latLng);
latLngBounds = L.latLngBounds(latLngLiteral, latLngLiteral);
latLngBounds = L.latLngBounds(latLngTuple, latLngTuple);
latLngBounds = L.latLngBounds(latLngBoundsLiteral);
latLngBounds = L.latLngBounds([latLngLiteral, latLngLiteral, latLngLiteral]);
latLngBounds = L.latLngBounds([latLng, latLng, latLng]);

latLngBounds = new L.LatLngBounds(latLng, latLng);
latLngBounds = new L.LatLngBounds(latLngLiteral, latLngLiteral);
latLngBounds = new L.LatLngBounds(latLngTuple, latLngTuple);

const pointTuple: L.PointTuple = [0, 0];

let point: L.Point;
point = L.point(12, 13);
point = L.point(12, 13, true);
point = L.point(pointTuple);
point = L.point({x: 12, y: 13});

point = new L.Point(12, 13);
point = new L.Point(12, 13, true);

let distance: number;
point.distanceTo(point);
point.distanceTo(pointTuple);

const transformation = new L.Transformation(1, 2, 3, 4);
point = transformation.transform(point);
point = transformation.transform(point, 2);
point = transformation.untransform(point);
import * as L from 'leaflet';
import 'leaflet-label';

const map: L.Map = L.map('map-container');
let label: L.Label;

// Icon
const icon: L.Icon = new L.Icon({ labelAnchor: L.point(1, 1) });

// CircleMarker
let circleMarker: L.CircleMarker = new L.CircleMarker(new L.LatLng(0, 0), { labelAnchor: L.point(1, 1) });

circleMarker = circleMarker.bindLabel('test', {
	className: 'thingy',
	clickable: true,
	direction: 'right',
	noHide: false,
	offset: new L.Point(0, 0),
	opacity: 0.5,
	zoomAnimation: true,
});

circleMarker.showLabel();
circleMarker.hideLabel();
circleMarker.setLabelNoHide(true);
circleMarker.updateLabelContent('test2');
label = circleMarker.getLabel();
circleMarker = circleMarker.unbindLabel();

// Marker
let marker = new L.Marker(new L.LatLng(0, 0));
Пример #5
0
        const innerIconStyle = this.getInnerIconStyle(options);
        if (options.isAlphaNumericIcon) {
            return '<div style="' + innerIconStyle + '">' + options.text + "</div>";
        }

        let spinClass = "";
        if (options.spin) {
            spinClass = " fa-spin";
        }

        return '<i class="' + options.prefix + " " + options.icon + spinClass + '" style="' + innerIconStyle + '"></i>';
    },

    getInnerIconStyle(options) {

        const innerAnchor = point(options.innerIconAnchor);
        return "color:" + options.textColor + ";margin-top:" + innerAnchor.y + "px; margin-left:" + innerAnchor.x + "px;" + options.innerIconStyle;
    },

    _setIconStyles(iconDiv) {

        const options = this.options;
        const size = point(options.iconSize);
        const anchor = point(options.iconAnchor);

        iconDiv.className = "beautify-marker ";

        if (options.iconShape) {
            iconDiv.className += options.iconShape;
        }