【发布时间】:2020-07-22 11:27:30
【问题描述】:
enter image description herei"我愿意在我的应用中使用此功能,当我滚动地图时,标记会自动拖动,就像在 uber 和 careem 应用中一样。
【问题讨论】:
标签: reactjs google-maps react-native-android react-native-maps
enter image description herei"我愿意在我的应用中使用此功能,当我滚动地图时,标记会自动拖动,就像在 uber 和 careem 应用中一样。
【问题讨论】:
标签: reactjs google-maps react-native-android react-native-maps
您可以使用图像或图标创建客户标记,然后您可以使用
<MapView
....
onRegionChangeComplete={(region) => {
this.setLocation(region);}>
然后您可以在滚动时 setState 更新的区域。
setLocation = (region) => {
try {
if (region && region.longitude !== 0) {
const latitude = region.latitude;
const longitude = region.longitude;
if (
latitude.toFixed(6) == this.state.region.latitude.toFixed(6) &&
longitude.toFixed(6) == this.state.region.longitude.toFixed(6)
) {
return false;
} else {
this.setState({region}, () => {
console.log('New Region', this.state.region);
});
}
}
} catch {
Alert.alert('App name', 'Location Permission not granted');
}
};
这可能对你有帮助。
【讨论】: