当我尝试将标记添加到GoogleMaps地图时出现此错误:
com.google.maps.api.android.lib6.common.apiexception.c: Not on the main thread
该如何解决?
-这是产生标记的类:
public class MobSpawner {
public LatLng posPlayer=new LatLng(1,1);
Randomizzatore valori=new Randomizzatore();
public void setPosPlayer(LatLng posPlayer) {
this.posPlayer = posPlayer;
}
public void spawna(){
Marker mPosMostro;
LatLng posMostro=new LatLng(valori.randomCoord(posPlayer.latitude),valori.randomCoord(posPlayer.longitude));
mPosMostro = MapsActivity.mMap.addMarker(new MarkerOptions().position(posMostro).title("mostroo"));
}}