I"m new with google maps, I'am doing an android application in which I want to make a button , which on click shows a map with a pin on a certain place that i previously declared (i already have the longitude and latitude). I also want the user to be able to click a button in order to be able to open google maps and make a pin on the map himself. Any ideas or examples for a similar code? Thanks in advance.
Asked
Active
Viewed 866 times
2 Answers
2
A good place to start would be to read some tutorials on the Google Maps API for Android. Look here, for example.
Don't forget to select in Eclipse ADT, the target API to "Google API". That's the way you are supposed to access the Android Google Maps API.

MobileCushion
- 7,065
- 7
- 42
- 62
0
for eg.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView;
mapView = new MapView(this,data.getAPIKEY());
mapView.setClickable(true);
setContentView(mapView);
GeoPoint srcGeoPoint = new GeoPoint(22, 70);
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable srcdrawable = this.getResources().getDrawable(R.drawable.pin_green);
CustomItemizedOverlay srcitemizedOverlay = new CustomItemizedOverlay(srcdrawable);
OverlayItem srcoverlayitem = new OverlayItem(srcGeoPoint, "Hello!", "This is your Location.");
srcitemizedOverlay.addOverlay(srcoverlayitem);
mapOverlays.add(srcitemizedOverlay);
mapView.setBuiltInZoomControls(true);
mapView.displayZoomControls(true);
mOverlays = mapView.getOverlays();
mapView.getController().animateTo(srcGeoPoint);
mapView.getController().setZoom(12);
}
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
private Drawable getDrawable(String fileName)
{
return Drawable.createFromStream(_activity.getClass().getClassLoader().getResourceAsStream(fileName), "pin");
}

Chintan Raghwani
- 3,370
- 4
- 22
- 33
-
put "pin_green" named image file in your drawable folder – Chintan Raghwani May 11 '12 at 15:24