I'm creating an android app that deals with Points of Interest ! I have also created a local database in which there is a table with all the information about a Poi (name,category,type,longitude,latitude). I have added several Pois in the database and now I want to add them as markers on google maps .
The problem is that I don't know how to do it exactly. I have search several tutorials on the internet but nothing works as I don't want to add a Marker with constant longitude,latitude , but I want to take them from the database.
Also my db method is using a rawQuery , because I want the longitude and a latitude of the returned Pois to be BETWEEN two values , so I can't find out how to take the columns from it in order to use it later in creating the Poi marker !
for(PoiModel poi : PoiHelper.mpoi){
markerPoi = new MarkerOptions();
LatLng tag = new LatLng(poi.getY(),poi.getX());
markerPoi.position(tag)
.title(poi.getName())
.snippet(poi.getCategory());
map.addMarker(markerPoi);
}
Since you are returning an array I think you shoul do something like this in your map acitivity:
private GoogleMap mMap;
private MapView mMapView;
mMapView = (MapView)findViewById(R.id.map);
mMap = mMapView.getMap();
for( PoiModel mypoi : poi)
{
markerPOI = new MarkerOptions();
markerPOI .position(new LatLng(mypoi .getLatitude(),mypoi .getLongitude()))
.title(mypoi .getName())
.snippet(mypoi .getCategory())
mMap.addMarker(markerPOI );
}