leaflet#PointTuple TypeScript Examples

The following examples show how to use leaflet#PointTuple. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Pl3xmapMapProvider.ts    From LiveAtlas with Apache License 2.0 6 votes vote down vote up
private static buildCircle(id: string, circle: any): LiveAtlasCircleMarker {
		const radius = [circle.radiusX || circle.radius || 0, circle.radiusZ || circle.radius || 0] as PointTuple,
			location = {
				x: circle.center?.x || 0,
				y: 0,
				z: circle.center?.z || 0,
			};

		return {
			id,
			type: LiveAtlasMarkerType.CIRCLE,
			location,
			radius,
			bounds: {
				max: {x: location.x + radius[0], y: 0, z: location.z + radius[1] },
				min: {x: location.x - radius[0], y: 0, z: location.z - radius[1] },
			},
			style: {
				stroke: (typeof circle.stroke === 'undefined' || !!circle.stroke) && !!circle.color,
				color: circle.color || '#3388ff',
				weight: circle.weight || 3,
				opacity: typeof circle.opacity !== 'undefined' ? circle.opacity : 1,
				fill: (typeof circle.fill === 'undefined' || !!circle.fill) && !!circle.fillColor,
				fillColor: circle.fillColor || circle.color || '#3388ff',
				fillOpacity: circle.fillOpacity || 0.2,
				fillRule: circle.fillRule,
			},

			tooltip: circle.tooltip ? stripHTML(circle.tooltip) : '',
			tooltipHTML: circle.tooltip,
			popup: circle.popup,
			isPopupHTML: true,
		};
	}
Example #2
Source File: dynmap.ts    From LiveAtlas with Apache License 2.0 6 votes vote down vote up
function buildMarker(id: string, data: Marker, config: DynmapUrlConfig): LiveAtlasPointMarker {
	let dimensions;

	if(data.dim) {
		dimensions = data.dim.split('x').filter(value => !isNaN(Number(value)));

		if(dimensions.length !== 2) {
			dimensions = undefined;
		}
	}

	const marker = {
		id,
		type: LiveAtlasMarkerType.POINT,
		location: {
			x: !isNaN(data.x) ? Number.isInteger(data.x) ? data.x + 0.5 : data.x : 0,
			y: !isNaN(data.y) ? Number.isInteger(data.y) ? data.y + 0.5 : data.y : 0,
			z: !isNaN(data.z) ? Number.isInteger(data.z) ? data.z + 0.5 : data.z : 0,
		},
		iconUrl: `${config.markers}_markers_/${data.icon || "default"}.png`,
		iconSize: (dimensions || [16, 16]) as PointTuple,
		minZoom: typeof data.minzoom !== 'undefined' && data.minzoom > -1 ? data.minzoom : undefined,
		maxZoom: typeof data.maxzoom !== 'undefined' && data.maxzoom > -1 ? data.maxzoom : undefined,
		tooltip: data.markup ? stripHTML(data.label) : data.label,
		tooltipHTML: data.markup ? data.label : undefined,
		popup: data.desc || undefined,
		isPopupHTML: true,
	} as LiveAtlasPointMarker;

	//Fix double escaping on non-HTML labels
	if(!marker.tooltipHTML) {
		marker.tooltip = decodeHTMLEntities(marker.tooltip);
	}

	return marker;
}