nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 699 forks source link

Help Needed : Need to show custom tile on map #1601

Closed ManishSharmaApporio closed 5 years ago

ManishSharmaApporio commented 5 years ago

Hi,

I have my own custom tile server and i want to show custom tiles on map.but as i have tried with styleURL but its not works.Please let me know how can i show custom tile on map.Thanks

tylergaw commented 5 years ago

@ManishSharmaApporio I had a similar need a while back. PR here with an example https://github.com/nitaliano/react-native-mapbox-gl/pull/1449

systemlevel commented 5 years ago

@ManishSharmaApporio I am serving custom tiles from our own tile server. I'm not sure if you are serving Raster or Vector data but this is how I serve Raster layers:

  const rasterSourcePropsTrails = {
    id: 'rasterSourcePropsTrails',
    url: 'http://yourserverhere.com/data/Trails/{z}/{x}/{y}.png',
    tileSize: 256,
  };

Now add a RasterSource and RasterLayer

        <Mapbox.RasterSource {...rasterSourcePropsTrails}>
          <Mapbox.RasterLayer
            id="layerTrails"
            style={{ visibility: (layers.trails.show ? "visible" : "none"), rasterOpacity: layers.trails.opacity}}
          />
        </Mapbox.RasterSource>

See this example for more info: https://github.com/nitaliano/react-native-mapbox-gl/blob/master/example/src/components/WatercolorRasterTiles.js

The new updated repo is coming together over here: https://github.com/react-native-mapbox/maps