我正在使用react-google-maps,并且遵循该示例:LINK。我正在获取来自GPS设备的数据,我想在获取新数据时居中。
这是整个地图组件的代码:
const GettingStartedGoogleMap = withGoogleMap(props => (
<GoogleMap
ref={props.onMapLoad}
defaultZoom={18}
defaultCenter={props.defCenter}
onClick={props.onMapClick}
>
{props.markers.map((marker,i) => (
<Marker
key={i}
position={marker.location}
time={marker.time}
onClick={() => props.onMarkerClick(marker)}
>
{ marker.isShown &&
<InfoWindow onCloseClick={() => props.onMarkerClick(marker)}>
<div className="marker-text">{marker.time} </div>
</InfoWindow>
}
</Marker>
))}
</GoogleMap>
));
class GettingStartedExample extends Component {
componentDidMount(){
this.props.fetchMarkers();
console.log("MONT");
console.log(this.props.markers.length);
}
componentWillReceiveProps(){
console.log(this.props.markers);
console.log(this.props.markers.length);
}
state = {
markers: this.props.markers,
center: {lat: 50.07074, lng: 19.915718},
};
handleMapLoad = this.handleMapLoad.bind(this);
handleMarkerClick = this.handleMarkerClick.bind(this);
handleMapLoad(map) {
this._mapComponent = map;
if …Run Code Online (Sandbox Code Playgroud) 你好我想写一个有2个并发线程的程序。第一个线程写入数组字母“A”,第二个线程写入“B”。我的问题是如何使用关键部分通过仅包含字母 A 和仅包含字母 B 的交替数组获得结果?这是我的代码,但它不能正常工作。这有什么问题吗?
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <psapi.h>
#define SIZE_TAB 200
volatile char program[SIZE_TAB];
CRITICAL_SECTION CriticalSection;
DWORD WINAPI aa(void *v);
DWORD WINAPI bb(void *v);
int main(int argc, char *argv[])
{
InitializeCriticalSection(&CriticalSection);
HANDLE thread_a = CreateThread(NULL, 0, aa, 0, 0, 0);
HANDLE thread_b = CreateThread(NULL, 0, bb, 0, 0, 0);
while (1)
{
for (int i = 0; i<SIZE_TAB; i++)
printf("%c", program[i]);
Sleep(1000);
printf("\n\n");
}
DeleteCriticalSection(&CriticalSection);
CloseHandle(thread_a);
CloseHandle(thread_b);
return 0;
}
DWORD WINAPI aa(void *v)
{ …Run Code Online (Sandbox Code Playgroud)