81 lines
1.5 KiB
Java
81 lines
1.5 KiB
Java
package org.thinkname.ap.main;
|
|
|
|
import org.thinkname.ap.contact.ContactLocation;
|
|
import org.thinkname.ap.contact.ContactManager;
|
|
|
|
import com.google.android.maps.GeoPoint;
|
|
import com.google.android.maps.MapController;
|
|
import com.google.android.maps.MapView;
|
|
|
|
public class FocusPoint {
|
|
|
|
private String id;
|
|
private MapController mapController;
|
|
private Thread t;
|
|
private int refreshTime=1000;
|
|
private boolean foucsState;
|
|
|
|
|
|
|
|
|
|
public FocusPoint(MapView myMapView,String id)
|
|
{
|
|
this.mapController = myMapView.getController();
|
|
this.id=id;
|
|
this.foucsState=false;
|
|
|
|
}
|
|
|
|
|
|
public void startFocus()
|
|
{
|
|
|
|
t=new Thread(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
|
|
while(foucsState)
|
|
{
|
|
ContactLocation cl=ContactManager.getInstance().getAllContactLocations().get(id);
|
|
int latitudeE6= (int)(cl.getLatitude()*1E6);
|
|
int longitudeE6=(int)(cl.getLongitude()*1E6);
|
|
|
|
//mapController.setCenter(new GeoPoint(latitudeE6,longitudeE6));//设为中心
|
|
mapController.animateTo(new GeoPoint(latitudeE6,longitudeE6));//滑动过去
|
|
try {
|
|
Thread.sleep(refreshTime);
|
|
} catch (InterruptedException e) {
|
|
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|
|
});
|
|
t.start();
|
|
|
|
}
|
|
|
|
public void stopFocus()
|
|
{
|
|
if(t!=null&&t.isAlive())
|
|
try {
|
|
t.join();
|
|
t.stop();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
public boolean isFoucsState() {
|
|
return foucsState;
|
|
}
|
|
|
|
|
|
public void setFoucsState(boolean foucsState) {
|
|
this.foucsState = foucsState;
|
|
}
|
|
|
|
}
|