Skip to content

Infinite effect loop using the GeolocateControl component after 1.0.0 #123

@dimitarnikolovv

Description

@dimitarnikolovv

After updating to 1.0.0, I have noticed that the <GeolocateControl/> causes an infinite effect loop.

Example with problem:

<MapLibre
	onload={(e) => {...}}
	{bounds}
	{maxBounds}
	{zoom}
	{center}
	renderWorldCopies={false}
	onzoom={(e) => {...}}
	onmovestart={(e) => {...}}
	onmoveend={(e) => {...}}
	onclick={(e) => {...}}
	class="bg-background isolate h-full w-full"
	attributionControl={false}
	{style}
>
	<NavigationControl position="top-left" visualizePitch />

        <!-- THIS CAUSES INFINITE EFFECT LOOP -->
	<GeolocateControl position="top-left" />

	<ScaleControl position="bottom-left" />
	<FullScreenControl position="top-left" />

	{@render children?.()}
</MapLibre>

The error:

Image

$effect(() => {
	control && mapCtx.map?.removeControl(control);
	control = new maplibregl.GeolocateControl(options);
	mapCtx.map?.addControl(control, position);
});

If <GeolocateControl position="top-left" /> is removed, there is no problem.

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is neededquestionFurther information is requested

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions