小编Eln*_*naz的帖子

27
推荐指数
5
解决办法
3万
查看次数

获取osmdroid中地图上单击位置的纬度和经度

我已经设法用它来编写一个Android应用程序来跟踪用户位置并使用标记在地图上显示它.这是相关代码:

public class MainActivity extends Activity implements LocationListener {

public MapView mapView;
private LocationManager locationManager;
MyItemizedOverlay myItemizedOverlay = null;
Drawable marker;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mapView = (MapView) this.findViewById(R.id.mapview);
    mapView.setUseDataConnection(false);
    mapView.setClickable(true);
    mapView.setBuiltInZoomControls(true);
    mapView.setMultiTouchControls(true);
    mapView.setUseDataConnection(false);
    mapView.setFocusable(true);
    mapView.setFocusableInTouchMode(true);

    mapView.getController().setZoom(16); // set initial zoom-level, depends
                                            // on your need
    marker = getResources().getDrawable(android.R.drawable.star_on);
    int markerWidth = 1;
    int markerHeight = 1;
    marker.setBounds(0, markerHeight, markerWidth, 0);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
            0, this); // You can also use LocationManager.GPS_PROVIDER and
                        // …
Run Code Online (Sandbox Code Playgroud)

android dictionary onclick osmdroid

6
推荐指数
1
解决办法
6136
查看次数

标签 统计

android ×2

dictionary ×1

icons ×1

material-design ×1

onclick ×1

osmdroid ×1