简体   繁体   中英

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. 地图标记

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 is a key-value database for Android it's an alternative for SQLite if you want to use a NoSQL approach.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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