在使用 ReactJS 获取她的坐标后,我正在使用react-google-maps来显示用户的位置。但是,当我从原始位置移动标记时,初始标记停留在那里,因此创建了两个标记。我不知道如何解决这个问题。
我希望无论发生什么,地图标记都保持在中心,而且当用户拖动或放大/缩小标记时,标记保持在中心,以便用户的位置始终位于地图的中心。通过这种方式,用户将能够更新她的位置。根据您的示例,当我拖动时,标记保持固定在其位置此组件的设计使用户可以设置她的位置,只需稍微调整标记的位置,以防标记有点偏离任何帮助将不胜感激:
应用程序.js
import React from "react";
import WrappedMap from "./Map";
import "./styles.css";
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
location: "",
place: ""
};
}
handleLocation = (location) => {
this.setState({ location: location });
};
handlePlace = (place) => {
this.setState({ place: place });
};
render() {
return (
<div className="App">
<WrappedMap
googleMapURL={`https://maps.googleapis.com/maps/api/js?key=`}
loadingElement={<div style={{ height: `100%` }} />}
containerElement={
<div
style={{
height: `50%`,
width: "95%",
position: "absolute",
marginTop: …Run Code Online (Sandbox Code Playgroud) javascript google-maps google-maps-markers reactjs react-google-maps
我有一个MainFooter包含页脚和迷你播放器的组件,单击时可动画显示为全视图。我有一个问题,每当我们点击一个页脚选项卡时,播放器最大化然后卡在那里,没有响应。
此外,播放器内部的向下箭头图标在单击时不会将其最小化,单击 MiniPlayer 也不会将其最大化,但是我们可以通过单击并将其拖动到全视图来最大化 MiniPlayer,对于最大化的 Player 也是如此。
这是MainFooter组件:
export const MainFooter = ({ setCounter, counter }: Props) => {
const translationY = new Value(0);
const velocityY = new Value(0);
const state = new Value(State.UNDETERMINED);
const offset = new Value(SNAP_BOTTOM);
const goUp: Animated.Value<0 | 1> = new Value(0);
const goDown: Animated.Value<0 | 1> = new Value(0);
const gestureHandler = onGestureEvent({
state,
translationY,
velocityY,
});
const translateY = clamp(
withSpring({
state,
value: translationY,
velocity: velocityY,
snapPoints: [SNAP_TOP, SNAP_BOTTOM], …Run Code Online (Sandbox Code Playgroud) animation react-native react-animated react-native-reanimated react-native-gesture-handler
animation ×1
google-maps ×1
javascript ×1
react-native ×1
react-native-gesture-handler ×1
reactjs ×1