如何在Android中使用的标记显示地图标记、地图、如何在、Android

由网友(凹凸曼biu)分享简介:我的工作在Android上的应用程序,我在这个完全newbe。所以我想知道如何在地图以及如何显示标记改变他的立场的具体时间像定义线程或任何在后台将发送上的纬度和经度值和标记是移动I am working on android app and I am totally newbe in this. So I want...

我的工作在Android上的应用程序,我在这个完全newbe。所以我想知道如何在地图以及如何显示标记改变他的立场的具体时间像定义线程或任何在后台将发送上的纬度和经度值和标记是移动

I am working on android app and I am totally newbe in this. So I want to know how to display marker in map and how to change his position on specific time like defining thread or anything in background which will send the latitude and longitude value and marker was move on that

推荐答案

如果你要只显示一个单一的项目, MapView.addView()后来更新与 setLayoutParams 位置是卓有成效的。

If you're going to show just a single item, MapView.addView() and later updating position with setLayoutParams does the trick.

private ImageView mCurrentPointer;

@Override
public void onLocationChanged(Location l) {
    int latitude = (int) (l.getLatitude() * 1e6);
    int longitude = (int) (l.getLongitude() * 1e6);
    // Prepare new LayoutParams object that centers on our new latitude/longitude
    MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, 
            MapView.LayoutParams.WRAP_CONTENT, new GeoPoint(latitude, longitude),
            MapView.LayoutParams.CENTER);

    if (mCurrentPointer == null) {
        // If "current location" pin is null, we haven't added it
        // to MapView yet. So instantiate it and add it to MapView:
        mCurrentPointer = new ImageView(this); 
        mCurrentPointer.setImageResource(R.drawable.ic_maps_indicator_current_position);
        mMapView.addView(mCurrentPointer, lp);
    } else {
        // If it's already added, just update its location
        mCurrentPointer.setLayoutParams(lp);
    }
}

编辑

链接,更多的例子和教程

links for more examples and tutorials

http://mobiforge.com/developing/story/using-google-maps-android

http://www.vogella.de/articles/AndroidLocationAPI/article.html

Android的谷歌地图标记

Show标志上的谷歌地图的位置从XML 获得

Add使用谷歌地图的Andr​​oid 标记的触摸位置

阅读全文

相关推荐

最新文章