mapbox警告setAccessToken需要Maplibre空白屏幕的SetWell Novenneftileserver- REECT Native Expo

发布于 2025-02-13 12:12:11 字数 1191 浏览 3 评论 0原文

app.js

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import MapboxGL from '@rnmapbox/maps';
MapboxGL.setAccessToken('TOKEN');
export default function App() {
  return (
    <View style={styles.page}>
          <MapboxGL.MapView style={styles.map} />
          <StatusBar style="auto"/>
      </View>
  );
}

const styles = StyleSheet.create({
  page: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF'
  },
  map: {
    flex: 1
  }
});

给出此错误: 错误

mapbox警告setAccessToken要求setwellnoinefiteleserver用于maplibre,请参见setwellnoichnoichtileserver docs有关含义对象{ “等级”:“警告”, “消息”:“ setAccessToken要求Maplibre需要SetWellnonningtileserver,请参阅Setwellnoynnoichtileserver Docs有关含义”, “ tag”:“ instancemanagerimpl”,

和空白屏幕: 空白反应本机屏幕

App.js

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import MapboxGL from '@rnmapbox/maps';
MapboxGL.setAccessToken('TOKEN');
export default function App() {
  return (
    <View style={styles.page}>
          <MapboxGL.MapView style={styles.map} />
          <StatusBar style="auto"/>
      </View>
  );
}

const styles = StyleSheet.create({
  page: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF'
  },
  map: {
    flex: 1
  }
});

Giving this error :
Error

Mapbox warning setAccessToken requires setWellKnownTileServer for MapLibre, see setWellKnownTileServer docs for implications Object {
"level": "warning",
"message": "setAccessToken requires setWellKnownTileServer for MapLibre, see setWellKnownTileServer docs for implications",
"tag": "InstanceManagerImpl",

And blank screen:
blank react native screen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丿*梦醉红颜 2025-02-20 12:12:12

您的地图无需显示。添加 stylejson styleurl 选项。例如(OSM图块):

const defaultStyle = {
  version: 8,
  name: 'Land',
  sources: {
    map: {
      type: 'raster',
      tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],
      tileSize: 256,
      minzoom: 1,
      maxzoom: 19,
    },
  },
  layers: [
    {
      id: 'background',
      type: 'background',
      paint: {
        'background-color': '#f2efea',
      },
    },
    {
      id: 'map',
      type: 'raster',
      source: 'map',
      paint: {
        'raster-fade-duration': 100,
      },
    },
  ],
};

// -- map component
<MapboxGL.MapView
  style={styles.map}
  styleJSON={JSON.stringify(defaultStyle)}
/>

Your map has nothing to show. Add styleJSON or styleURL option. For example (osm tiles):

const defaultStyle = {
  version: 8,
  name: 'Land',
  sources: {
    map: {
      type: 'raster',
      tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],
      tileSize: 256,
      minzoom: 1,
      maxzoom: 19,
    },
  },
  layers: [
    {
      id: 'background',
      type: 'background',
      paint: {
        'background-color': '#f2efea',
      },
    },
    {
      id: 'map',
      type: 'raster',
      source: 'map',
      paint: {
        'raster-fade-duration': 100,
      },
    },
  ],
};

// -- map component
<MapboxGL.MapView
  style={styles.map}
  styleJSON={JSON.stringify(defaultStyle)}
/>
红颜悴 2025-02-20 12:12:12

我通过在我的代码中添加一行来解决它:

mapboxgl.setwellnovennonningtileserver('mapbox');

I solved it by adding one line to my code:

MapboxGL.setWellKnownTileServer('Mapbox');

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文