You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native Expo MapView Marker属性类型错误求助

问题解决:React Native Maps Marker 类型错误

问题根源

你导入Marker的方式完全错了。react-native-maps里,MapView是默认导出,但Marker是命名导出,你现在的写法:

import Marker from 'react-native-maps';

相当于把MapView组件重新赋值给了Marker变量,所以你实际渲染的是MapView而非Marker,自然会报coordinate属性不存在的类型错误——因为MapView根本不需要这个属性。

修正方案

把导入语句改成解构导入Marker:

import { StyleSheet, Image, Platform, View } from 'react-native';
import MapView, { Marker } from 'react-native-maps'; // 修正为解构导入
import React, { useState } from 'react';

验证

你的Marker组件的props写法本身是正确的,修正导入后,类型错误会直接消失,组件能正常渲染带自定义图标的标记点。

内容的提问来源于stack exchange,提问作者Beanz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 12:12:11