本文介绍了如何使用OSM地图Android应用程序?是否有任何教程,以了解在Android中使用OSM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜从过去一个星期我在寻找一个教程/手动或步骤的家伙,包括开放街道地图在我的Andr​​oid应用程序。所有我发现无论是与它更多的功能,一个大项目,否则这么多的问题没有关于正确结论结束了如何做..!

Hi guys from past one week i'm searching for a tutorial/manual or steps to include Open street map into my android application. All i found is either a big project with lot more functionality on it, otherwise so many questions ended without proper conclusion about "HOW"..!

有没有合适的博客/网站或文件,可以将新鲜可以参考?

Is there any proper blog/site or document that can a fresher can refer.?

推荐答案

我不知道任何教程,但这里的code我写了使用Osmdroid一个小例子。

I don't know of any tutorials but here's the code I wrote for a minimal example using Osmdroid.

// This is all you need to display an OSM map using osmdroid
package osmdemo.demo;

import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.app.Activity;
import android.os.Bundle;

public class OsmdroidDemoMap extends Activity {
    private MapView         mMapView;
    private MapController   mMapController;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.osm_main);
        mMapView = (MapView) findViewById(R.id.mapview);
        mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
        mMapView.setBuiltInZoomControls(true);
        mMapController = (MapController) mMapView.getController();
        mMapController.setZoom(13);
        GeoPoint gPt = new GeoPoint(51500000, -150000);
        mMapController.setCenter(gPt);
    }
}
/* HAVE THIS AS YOUR osm_main.xml
---------------------------------------------------------- XML START
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <org.osmdroid.views.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true" />
</LinearLayout>
---------------------------------------------------------- XML END
Include slf4j-android-1.5.8.jar and osmdroid-android-4.1.jar in the build path
(Google search for where to get them from)
*/

请注意,您现在必须使用最新的版本(4.1),以避免从OSM下载瓦片被阻塞。

Note that you must now use the latest version (4.1) to avoid getting blocked from downloading tiles from OSM.

另外请注意,他们正在自己的repositries到Github上,过程尚未完成。此网页。下载持有环节的罐子

Also note that they are moving their repositries to Github and the process isn't complete yet. This page downloads holds the links for the jars

这篇关于如何使用OSM地图Android应用程序?是否有任何教程,以了解在Android中使用OSM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 00:01