Skip to content

Commit

Permalink
feat(map): 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxingkang committed Jan 18, 2024
1 parent 83801a2 commit 75a9fcd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/map/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,20 @@ export const Map = forwardRef<Mapbox.Map, MapProps>((props, ref) => {
return options as Mapbox.MapboxOptions;
};

const CHILD_CONTAINER_STYLE = {
height: '100%',
};

return (
<div ref={containerRef} style={style} className={className}>
{!mapInstance && loading}
{mapInstance && <MapContext.Provider value={contextValue}>{children}</MapContext.Provider>}
{mapInstance && (
<MapContext.Provider value={contextValue}>
<div mapboxgl-children="" style={CHILD_CONTAINER_STYLE}>
{children}
</div>
</MapContext.Provider>
)}
</div>
);
});

0 comments on commit 75a9fcd

Please sign in to comment.