Android编程,mapview位置叠加:如何使用其他图像更改默认的蓝色位置点 [英] Android programming, mapview location-overlay: how to change the default blue location dot, with another image

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

问题描述

我需要弄清楚如何用图像更改默认的我的位置"蓝点,其作用方式也与指北针指向行进方向的方式相同.这可以通过设备罗盘或通过GPS检测行进方向来解决

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

我已经做了一些谷歌搜索,但是到目前为止,我只找到了在iPhone上更改点的方法的参考,并且我正在使用Android ...

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

亲切的问候

尼克

在OnCreate中:

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仅返回0.0.尝试使用旋转当前位置图标

位置管理器.getbearing()派上用场

the location manager .getbearing() comes in handy

致谢

尼克

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

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