Reactjs 如何在谷歌地图中添加标记移动动画?

Reactjs 如何在谷歌地图中添加标记移动动画?,reactjs,google-maps,google-maps-api-3,react-google-maps,Reactjs,Google Maps,Google Maps Api 3,React Google Maps,如何在React应用程序中实现标记移动动画。我用过谷歌地图 我正在浏览库和谷歌地图API的文档。谷歌地图API中有一个偏移选项。但我不是在找那个 应用程序将通过socket.io服务器接收更新的坐标。一旦坐标到达,就需要移动标记,就像Uber应用程序一样 GitHub上有一个尚未解决的问题 目前,我可以移动坐标更新上的标记,但不需要动画 示例代码 import React,{Component}来自'React'; 从“Socket.io客户端”导入套接字; 从“react router dom

如何在React应用程序中实现标记移动动画。我用过谷歌地图

我正在浏览库和谷歌地图API的文档。谷歌地图API中有一个偏移选项。但我不是在找那个

应用程序将通过socket.io服务器接收更新的坐标。一旦坐标到达,就需要移动标记,就像Uber应用程序一样

GitHub上有一个尚未解决的问题

目前,我可以移动坐标更新上的标记,但不需要动画

示例代码

import React,{Component}来自'React';
从“Socket.io客户端”导入套接字;
从“react router dom”导入{withRouter};
进口{
谷歌地图,
用ScriptJS,
用谷歌地图,
标记
}来自“谷歌地图反应”;
从“../../../config/constants”导入{googleMapsUrl,socketUrl};
const io=Socket(socketUrl('dev'));
类GoogleMaps扩展组件{
建造师(道具){
超级(道具);
此.state={
默认中心:{
clientId:“假客户ID”,
imei:“假imei号码”,
拉脱维亚:28.554907,
液化天然气:77.554385,
名字:“假名字”
},
默认缩放:10,
移动标记:[],
所有标记:[]
};
this.pullDataFromSocket=this.pullDataFromSocket.bind(this);
this.createMovingMarker=this.createMovingMarker.bind(this);
}
componentDidMount(){
这是.pullDataFromSocket();
}
pullDataFromSocket(){
const pathname=this.props.location.pathname.replace(/\/,“”);
io.on('data',data=>{
常量markerCoordinates=data.deviceCatalist.map(ds=>{
//一些有价值的修改
返回{
…ds
}
});
const movingMarker=this.state.movingMarker;
movingMarker.push(markerCoordinates[0]);
这是我的国家({
所有标记:标记协调,
defaultCenter:markerCoordinates[0],
移动标记
});
});
}
createMovingMarker(){
让MarkerLocation=this.state.defaultCenter;
如果(this.state.movingMarker.length>1){
/**
*将标记设置为更新的新位置
*/
MarkerLocation=this.state.movingMarker[this.state.movingMarker.length-1];
}
返回(
);
}
render(){
返回(
{this.createMovingMarker()}
)
};
}
const MapWrapper=withRouter(
用脚本(
使用谷歌地图(谷歌地图)
)
);
导出默认值()=>{
返回(
)
};