如何随着设备在android中移动而在谷歌地图上移动标记(当前标记)
如何随着设备移动(用户移动)在谷歌地图上移动标记(如点)......
import android.content.Context;
import android.widget.Toast;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
// This class subclasses (extends) MyLocationOverlay so that we can override its dispatchTap method
// to handle tap events on the present location dot.
public class MyMyLocationOverlay extends MyLocationOverlay {
private Context context;
public MyMyLocationOverlay(Context context, MapView mapView) {
super(context, mapView);
this.context = context; // Will need this for Toast argument below
}
// Override the dispatchTap() method to toggle the data display on and off when
// the present location dot is tapped. Also display a short Toast (transient message) to the
// user indicating the display status change.
@Override
protected boolean dispatchTap(){
if(DisplayOverlay.showData){
Toast.makeText(context, "Suppressing data readout", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context,"Display data readout", Toast.LENGTH_SHORT).show();
}
// Toggle the GPS data display
DisplayOverlay.showData = ! DisplayOverlay.showData;
return true;
}
how to moves marker(like dot) on google map as device moves (user moves).....
import android.content.Context;
import android.widget.Toast;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
// This class subclasses (extends) MyLocationOverlay so that we can override its dispatchTap method
// to handle tap events on the present location dot.
public class MyMyLocationOverlay extends MyLocationOverlay {
private Context context;
public MyMyLocationOverlay(Context context, MapView mapView) {
super(context, mapView);
this.context = context; // Will need this for Toast argument below
}
// Override the dispatchTap() method to toggle the data display on and off when
// the present location dot is tapped. Also display a short Toast (transient message) to the
// user indicating the display status change.
@Override
protected boolean dispatchTap(){
if(DisplayOverlay.showData){
Toast.makeText(context, "Suppressing data readout", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context,"Display data readout", Toast.LENGTH_SHORT).show();
}
// Toggle the GPS data display
DisplayOverlay.showData = ! DisplayOverlay.showData;
return true;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查我的帖子答案有链接。
如何在 Android 中显示带标记的地图
要在地图上移动标记,您需要在类中创建静态方法,该方法扩展 MapActivity,就像
扩展 Overlay 类的自定义覆盖类一样。
此处显示可绘制图像,使用 Bitmap 类在地图上绘制图像。
check my post answer there was link.
how to display map in android with marker
for moving marker on map you need to create the static method in the your class which extends the MapActivity like
your custom overlay class which extends the Overlay class.
here to display your drawable image display using Bitmap class to draw image on map.