(Android) Converting a database full of parking spot coordinates into pindrops on a map

102 views Asked by At

I am trying to fill areas of Seattle with pindrops that will provide information when pressed, but am trying to avoid hard coding each and every pindrop. I think it would be easiest to fill a database (SQLite) with the information and have a method that automatically converts the information into the pindrops, but I'd like to confirm this.

This is a super vague question, and I am just looking for someone to point me in a good direction as I have hit a wall. How should I be going about this? Would SQLite be the simplest solution? Is there an easier way? Thanks!!

3

There are 3 answers

1
Simas On BEST ANSWER

I think a SQLite database wrapped with a ContentProvider would be your best bet. If the coordinates you (will) have are lat lon, it will be cake to just convert them into markers on a map. Also depends what map you're planning of using.

For Google Maps API it would be as simple as:

// When CursorLoader finishes it calls onLoadFinished, there loop the returned data
// Table columns: float latitude, float longitude, String marker title
if (cursor.moveToFirst()) {
    for (int i=0; i<cursor.getCount(); i++ ) {
        mMap.addMarker(new MarkerOptions()
                .position(new LatLng(cursor.getFloat(0), cursor.getFloat(1)))
                .title(cursor.getString(2))
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));
    }
}
0
Jptalon On

Under 50 rep so I cannot comment, hence this here.

You can create pin drop points in html. Any database should work. Just grab all points as an array or json and combine it with the appropriate html in a loop function.

//Edit// I just noticed you tagged android. Scratch the html comment and check this out https://developers.google.com/maps/documentation/android/marker

0
someguy234 On

Yes using sqlite would be a totally better choice than hardcoding it into the app. You can then use PHP to read data from the sqlite database and display it on the page using google maps api or whatever you like.