rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.27k stars 849 forks source link

[Bug]: Update tileUrl not working #3611

Open yonitou opened 2 months ago

yonitou commented 2 months ago

Mapbox Implementation

Mapbox

Mapbox Version

10.1.30

React Native Version

0.74

Platform

iOS, Android

@rnmapbox/maps version

10.1.30

Standalone component to reproduce

import React, { useEffect, useState } from "react";
import { MapView, RasterLayer, RasterSource } from "@rnmapbox/maps";

const Component = () => {
    useEffect(() => {
        setInterval(() => {
            setCurrentWeather((prev) => prev >= prev + 1);
        }, 500);
    }, []);
    const [currentWeather, setCurrentWeather] = useState(0);
    return (
        <MapView styleURL="mapbox://styles/mapbox/satellite-streets-v12">
            <RasterSource
                id="stamen-watercolor"
                tileSize={256}
                tileUrlTemplates={[
                    `https://api.tomorrow.io/v4/map/tile/{z}/{x}/{y}/precipitationIntensity/${new Date(new Date().getTime() + currentWeather * 60 * 60 * 1000).toISOString()}.png?apikey=API_KEY`
                ]}
            />
            <RasterLayer id="stamen-watercolor-layer" sourceID="stamen-watercolor" style={{ rasterOpacity: 0.85 }} />
        </MapView>
    );
};

Observed behavior and steps to reproduce

When updating the prop tileURLTemplate, nothing happens. I checked the documentation and I don't find how to update a layer or a source like in the MapboxGL package for JS.

Expected behavior

The layer should update when updating the url

Notes / preliminary analysis

No response

Additional links and references

No response

yonitou commented 2 months ago

Hi,

Is it possible to have an answer ?

felixgourdeau commented 1 month ago

https://github.com/rnmapbox/maps/issues/2246

yonitou commented 1 month ago

@felixgourdeau already did that