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
|
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
ContentResolver cr = getContentResolver();
ContentValues newValues1 = new ContentValues();
newValues1.put(LocationsProvider.KEY_LOCATION_REGION,"NorthAfrica");
newValues1.put(LocationsProvider.KEY_LOCATION_LAT,"10.3");
newValues1.put(LocationsProvider.KEY_LOCATION_LNG,"23.14");
cr.insert(LocationsProvider.CONTENT_URI,newValues1);
ContentValues newValues2 = new ContentValues();
newValues2.put(LocationsProvider.KEY_LOCATION_REGION,"NorthAfrica");
newValues2.put(LocationsProvider.KEY_LOCATION_LAT,"10.3");
newValues2.put(LocationsProvider.KEY_LOCATION_LNG,"24.14");
cr.insert(LocationsProvider.CONTENT_URI,newValues2);
final MapView LocationMap=(MapView)findViewById(R.id.mapView);
Uri locationsURI= LocationsProvider.CONTENT_URI;
locationsCursor = getContentResolver().query(locationsURI,null,null,null,null);
// la méthode invokée ci- dessous permet de placer des points au positions
// dont les lat et long sont dans la base définie dans LocationsProvider
LocalisationOverlay eo=new LocalisationOverlay(locationsCursor);
// LocationMap est le nom du MapActivity
LocationMap.getOverlays().add(eo);
}
});
} |
Partager