1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Realm realm = Realm.getInstance(myContext);
RealmResults resultRealm = realm.allObjects(Restaurant.class);
for (int i = 0; i < resultRealm.size(); i++) {
Restaurant r = (Restaurant) resultRealm.get(i);
String name_restaurant = r.getName();
double latitude_restaurant = r.getLatitude();
double longitude_restaurant = r.getLatitude();
// Drawing marker on the map
MarkerOptions markerOptions = new MarkerOptions();
// Getting name
String name = "place_name";
double d = (double)latitude_restaurant;
double l = (double)longitude_restaurant;
LatLng latLng = new LatLng(d, l);
/* LatLng latLng = new LatLng(49.0445701, 2.0691226); */
// Setting the position for the marker
markerOptions.position(latLng);
// Setting the title for the marker.
//This will be displayed on taping the marker
markerOptions.title(name);
// Placing a marker on the touched position
mMap.addMarker(markerOptions);
} |
Partager