You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For an application I need to handle both online and offline mode. When in offline mode I wish to render the map using data stored in a json file that follows the Geojson format:
I was looking at a way to render only the necessary tiles, may be using the tileComponent prop of <Map /> combined with the geojson-vt library.
I manage to extract the coordinates of the tile I want to render from the tile argument of the tileComponent function and then get my Tile object using the geojson library. But now I am unsure how use this object to return a dom element from the tileComponent function.
Here what I have done so far (only the necessary code in included):
render(){constgeojsonTiles=geojsonvt(offlineGeojsonData);// offlineGeojsonData is imported from offlineMap.jsonconstcustomTileComponent=({ tile, tileLoaded })=>{constcoords=tile.key.split('-');constx=parseInt(coords[0]);consty=parseInt(coords[1]);constz=parseInt(coords[2]);consttileIndex=geojsonTiles.getTile(z,x,y);return(<GeoJsondata={tileIndex}/>// <-- This is where I struggle);}render(<MapdefaultCenter={[50.879,4.6997]}defaultZoom={11}height={600}tileComponent={customTileComponent}/>);}
Is there a way to achieve this using this library without the need to code low rendering layer like <svg> or <g> elements?
Or does anyone already faced this issue?
Any insight is welcome 😃
The text was updated successfully, but these errors were encountered:
Yes and I finally figured out how to make things work. The only issue that I have it that I am not able to integrate the geojon-vt functionality in this implementation.
Hello,
For an application I need to handle both online and offline mode. When in offline mode I wish to render the map using data stored in a json file that follows the Geojson format:
offlineMap.json:
I was looking at a way to render only the necessary tiles, may be using the
tileComponent
prop of<Map />
combined with the geojson-vt library.I manage to extract the coordinates of the tile I want to render from the
tile
argument of thetileComponent
function and then get myTile
object using thegeojson
library. But now I am unsure how use this object to return a dom element from thetileComponent
function.Here what I have done so far (only the necessary code in included):
Is there a way to achieve this using this library without the need to code low rendering layer like
<svg>
or<g>
elements?Or does anyone already faced this issue?
Any insight is welcome 😃
The text was updated successfully, but these errors were encountered: