lundi 22 décembre 2014

How to save extra marker info (HashMap) to SQlite database

I have markers that are added manually onto the map, and have implemented SQlite database to retrieve the markers once the user returns to the map. All of that works fine, but i can't seem to get the extra info added to the marker to display once the user taps on the marker (Custom Info Window)


So what i have done is I have created the fields in the database as then in my onMapLongClick is have added this:



contentValues.put(LocationsDB.FIELD_BMP, mImage + bitmap);


So in my mind it is telling me to save the mImage and the bitmap in that field to retrieve later.


Then when retrieving I have added this:



float img=0;

....

img = arg1.getFloat(arg1.getColumnIndex(LocationsDB.FIELD_BMP));

....

if(locationCount>0){

....

bitmap = myMimage.get(img);


So this is telling me to get the FIELD_BMP and place that image for that marker?


This is the code i am using to get the different info for each marker:



private Map<String, Bitmap> myMimage;
private String mImage;

\\Then in the onCreate method

myMimage = new HashMap<String, Bitmap>();

\\Then to display the phto in the custom info window

View v = getLayoutInflater().inflate(R.layout.custom_window, null);
final ImageView imgIcon = (ImageView) v.findViewById(R.id.marker_icon);
Bitmap bitmap = myMimage.get(marker.getId());
imgIcon.setImageBitmap(bitmap);


Then when placing the marker i use this:



Marker marker = googleMap.addMarker(new MarkerOptions()
.position(pointTappedOnMap));
mImage = marker.getId();


Everything works, it just doesn't save the image for that marker.

Please help me? Thanks in advance to all!!


Aucun commentaire:

Enregistrer un commentaire