Android的编程,图形页面locationoverlay:如何更改默认的蓝色圆点位置,与其他图像 [英] Android programming, mapview locationoverlay: how to change the default blue location dot, with another image

查看:182
本文介绍了Android的编程,图形页面locationoverlay:如何更改默认的蓝色圆点位置,与其他图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要工作,如何更改默认的我的位置蓝点与图像,这也将在同样的方式作为指向行进的方向指南针。这可以由该装置罗盘或通过检测从GPS行进方向被加工出

我做了一些谷歌上搜索,但到目前为止只发现更改iPhone上的点的方法的引用,而我与Android合作...

我想AP preciate一定的支持和指导,在这种

亲切的问候

尼克

在OnCreate中:
        的LocationManager locman =(的LocationManager)getSystemService(Context.LOCATION_SERVICE);

  locman.requestLocationUpdates(LocationManager.GPS_PROVIDER,5000,2,LocationListener的);    //添加当前位置叠加到地图的MapView并打开地图的指南针    MyLocation myLocationOverlay =新MyLocation(这一点,MapView类);
    。调用MapView.getOverlays()加(myLocationOverlay);
    myLocationOverlay.enableMyLocation();
    myLocationOverlay.enableCompass();    。调用MapView.getOverlays()加(myLocationOverlay);
    mapView.postInvalidate();

在OnLocationChanged:

  dbllatitude = locFromGps.getLatitude();
        dbllongitude = locFromGps.getLongitude();
        dblaltitude = locFromGps.getAltitude();
轴承= locFromGps.getBearing();
     strlatitude = Double.toString(dbllatitude);
        strlongitude = Double.toString(dbllongitude);
        dblaltitude =(dblaltitude / 0.3048);        LocationText.setText(您现在的位置:纬度+ dbllatitude +经度:+ dbllongitude +海拔高度+ dblaltitude);        布尔hasbearing = locFromGps.hasBearing();
        如果(hasbearing = FALSE){            Toast.makeText(getApplicationContext(),没有关系,Toast.LENGTH_SHORT).show();        }
        其他
        {
            Toast.makeText(getApplicationContext(),我H​​AZ承:+轴承,Toast.LENGTH_SHORT).show();
        }
        MyLocation.mOrientation =轴承;


解决方案

有关谁都希望得到旋转用户位置图标看到帖子的类似的功能:

<一个href=\"http://stackoverflow.com/questions/10258365/android-getbearing-only-returns-0-0-trying-to-use-to-rotate-current-location-ic\">Android getbearing只返回0.0。试图用旋转的当前位置图标

位置管理.getbearing()就派上用场了。

问候

尼克

I need to work out how to change the default 'my location' blue dot with an image, that will also act in the same fashion as a compass pointing the direction of travel. This can be worked out by the device compass or by detecting direction of travel from GPS

I've done some googling but so far only found a reference for the method of changing the dot on the iPhone, and I am working with Android...

I'd appreciate some support and guidance in this

Kind regards

Nick

In OnCreate: LocationManager locman = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    locman.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 2, locationListener); 

    //Adds a current location overlay to the map 'mapView' and turns on the map's compass

    MyLocation myLocationOverlay = new MyLocation(this, mapView);
    mapView.getOverlays().add(myLocationOverlay);
    myLocationOverlay.enableMyLocation();
    myLocationOverlay.enableCompass();

    mapView.getOverlays().add(myLocationOverlay);
    mapView.postInvalidate();

In OnLocationChanged:

dbllatitude = locFromGps.getLatitude();
        dbllongitude = locFromGps.getLongitude();
        dblaltitude = locFromGps.getAltitude();


bearing = locFromGps.getBearing(); 


     strlatitude = Double.toString(dbllatitude);
        strlongitude = Double.toString(dbllongitude);
        dblaltitude = (dblaltitude / 0.3048); 

        LocationText.setText("Your Location: Latitude " + dbllatitude + " Longitude: " +dbllongitude + " Altitude " + dblaltitude);



        boolean hasbearing = locFromGps.hasBearing();


        if (hasbearing =  false) {

            Toast.makeText(getApplicationContext(), "No bearing", Toast.LENGTH_SHORT).show();

        }
        else
        {
            Toast.makeText(getApplicationContext(), "I HAZ bearing: " + bearing, Toast.LENGTH_SHORT).show();
        }
        MyLocation.mOrientation = bearing;

解决方案

For anyone else looking to get similar functionality of rotating the user location icon see the post at:

Android getbearing only returns 0.0. Trying to use to rotate current location icon

the location manager .getbearing() comes in handy

Regards

Nick

这篇关于Android的编程,图形页面locationoverlay:如何更改默认的蓝色圆点位置,与其他图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆