Android: How to add pin to google maps
Possible Duplicate:
Best Way to Add Map Pins to Google Map Android
How to add pin and if clicked show balon with info address or city which I have custom getOverlay() in google maps API android.
Below my code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_map);
mapView = (MapView) findViewById(R.id.map_view);
GeoPoint gpStart = new GeoPoint((int) (-6.31689 * 1E6),
(int) (106.74040 * 1E6));
GeoPoint gpEnd = new GeoPoint((int) (-6.29729 * 1E6),
(int) (106.78386 * 1E6));
Route r = direction(gpStart, gpEnd);
RouteOverlay rOverlay = new RouteOverlay(r, Color.RED);
mapView.getOverlays().add(rOverlay);
mapView.getController().animateTo(gpStart);
mapView.getController().setZoom(15);
mapView.setBuiltInZoomControls(true);
}
My code have edited, Code in above i get from here and work for me, but not show pin on location. I know to put pin wich if code is standart from google maps V1. Just add overlay. But my problem is I get map from json array. So i want to add pin in location(geopoint) and if i click i get info address.
Thanks.
如果您使用的是Google Maps Android API v2,那么您应该这样做,这里记录它。
private GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.addMarker(new MarkerOptions()
.position(new LatLng(0, 0))
.title("Hello world"));
链接地址: http://www.djcxy.com/p/49624.html
下一篇: Android:如何添加pin到谷歌地图