简体   繁体   English

在Google Maps Android API中管理自己的路径的最佳方法

[英]Best way to manage my own paths in Google Maps Android API

I have to do a mobile application which will have my own paths that i have to put in the map, what is the best way to manage the paths? 我必须做一个移动应用程序,该应用程序将有我自己的路径,必须在地图中放置该路径,管理路径的最佳方法是什么? KML files with the paths and upload them to the map or a specific database for that purpose? 带有路径的KML文件,并为此将它们上传到地图或特定的数据库?

Well, I'm using a simple SQLite database for that and it works fine, first I save the locations as real types in the database and then I can save the locations on a list of LatLgn objects or on a hashmap with String key and Marker object, for example: 好吧,我为此使用了一个简单的SQLite数据库,它可以正常工作,首先,我将位置保存为数据库中的真实类型,然后可以使用String键和Marker将位置保存在LatLgn对象列表或哈希图上对象,例如:

private void getLatLgns() { 私人无效getLatLgns(){

    DBConnection dbc = new DBConnection(this, "MapsDB", null, 1); 
    SQLiteDatabase db = dbc.getWritableDatabase();

    Cursor c = db.rawQuery("SELECT Latitude,Longitude from Records", null);
    if(c.moveToFirst()){ 
        do {
            allLatLng.add(new LatLng(Double.parseDouble(c.getString(0)), Double.parseDouble(c.getString(1))));
        }while (c.moveToNext());
    }
    db.close();
}    

private void addingMarkers { 私人无效的addingMarkers {

for (int x= 0; x < allLatLng.size() ; x++) {
        hashMarkers.put(String.valueOf(x), mMap.addMarker(new MarkerOptions()
                .position(allLatLng.get(x)));
        Log.d("Position:", x + " " + allLatLng.get(x).latitude + " " + allLatLng.get(x).longitude);
    }

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM