简体   繁体   English

如何在Android应用中存储Google地图标记数据?

[英]How to store google map marker data in android app?

I have an activity that lets the user mark their route. 我有一个活动,可以让用户标记他们的路线。 I need to store the route as soon as the user is done with it. 用户完成操作后,我需要立即存储路由。 I will need to add a save button which allows the user to name the google map file and retrieve it later on the mobile. 我将需要添加一个保存按钮,该按钮允许用户命名google map文件并稍后在移动设备上检索它。 地图标记

How can i store the lat/lon of the markers in a file and then retrieve and plot it on the map, when the user opens the saved file. 当用户打开保存的文件时,如何将标记的纬度/经度存储在文件中,然后在地图上进行检索和绘制。

You can use SnappyDB 您可以使用SnappyDB

SnappyDB is a key-value database for Android it's an alternative for SQLite if you want to use a NoSQL approach. SnappyDB是Android 的键值数据库,如果您想使用NoSQL方法,它是SQLite的替代方法。

It allows you to store and get primitive types, but also a Serializable object or array in a type-safe way. 它允许您存储和获取基本类型,还可以以类型安全的方式存储和可序列化的对象或数组。

        try {
            DB snappydb = DBFactory.open(getActivity()); //create or open an existing databse using the default name

//Saving List of LatLng
            ArrayList<LatLng> listOfLatLng = new ArrayList<LatLng>();
            snappydb.put("LATLNG", listOfLatLng);


//Retrieving List of LatLngs
            ArrayList<LatLng> listOfLatLngNew = snappydb.get("LATLNG",ArrayList.class);


            snappydb.close();

        } catch (SnappydbException e) {
            e.printStackTrace();
        }

Installation 安装

dependencies {
    compile 'com.snappydb:snappydb-lib:0.5.2'
    compile 'com.esotericsoftware.kryo:kryo:2.24.0'
}

Reference Link 参考链接

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

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