을 사용하는 이전 앱에 Google Maps API V2 (MapFragment, Google Map, Marker 등)를 효과적으로 사용하는 방법은 Google지도 기반 프로젝트에서 6 개월 이상 . Google Maps API V1과 개발자 API 키를 사용하고있었습니다. 앱을 출시하려고 할 때 Google API V1이 사용되지 않음을 이해했습니다. 나는 구글지도 API V2에 대해 읽을 때, 나는지도보기, GeoPoint의, OverlayItem 보통 등의 단편, 마커, MapFragment가, 구글지도로 대체하는 것을 발견API V1 (MapView, GeoPoint 등),
내 원래 XML이<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="**************my old api key**************"/>
이제
구글과 같은
이 키를 제공하지 않아지도를 추가하고 동일한 오버레이 항목을 표시해야합니다. 나는이 새로운 API와 혼동 스럽다.
내 자바 파일은 정확히 내가 구글지도 API V2를 지원하기 위해 내 예전의 코드를 사용하기 위해 모든 수단이 있는지 알고 싶어
public class PlacesMapActivity extends MapActivity {
// Nearest places
PlacesList nearPlaces;
// Map view
MapView mapView;
// Map overlay items
List<Overlay> mapOverlays;
AddItemizedOverlay itemizedOverlay;
GeoPoint geoPoint;
// Map controllers
MapController mc;
Drawable defaultMarker;
double latitude;
double longitude;
OverlayItem overlayitem;
String p_u_name;
Place reference;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_places);
// Getting intent data
Intent i = getIntent();
reference = (Place) i.getSerializableExtra("place_reference");
// Users current geo location
String user_latitude = i.getStringExtra("user_latitude");
String user_longitude = i.getStringExtra("user_longitude");
// Nearplaces list
nearPlaces = (PlacesList) i.getSerializableExtra("near_places");
mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
// Geopoint to place on map
geoPoint = new GeoPoint((int) (Double.parseDouble(user_latitude) * 1E6),(int) (Double.parseDouble(user_longitude) * 1E6));
// Drawable marker icon
Drawable drawable_user = this.getResources().getDrawable(R.drawable.mark_red);
itemizedOverlay = new AddItemizedOverlay(drawable_user, this);
// Map overlay item
overlayitem = new OverlayItem(geoPoint, "Your Location","That is you!");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
itemizedOverlay.populateNow();
Drawable drawable = this.getResources().getDrawable(R.drawable.mark_blue);
itemizedOverlay = new AddItemizedOverlay(drawable, this);
mc = mapView.getController();
// These values are used to get map boundary area
// The area where you can see all the markers on screen
int minLat = Integer.MAX_VALUE;
int minLong = Integer.MAX_VALUE;
int maxLat = Integer.MIN_VALUE;
int maxLong = Integer.MIN_VALUE;
// check for null in case it is null
if (nearPlaces.results != null) {
// loop through all the places
for (Place place : nearPlaces.results) {
latitude = place.geometry.location.lat; // latitude
longitude = place.geometry.location.lng; // longitude
// Geopoint to place on map
geoPoint = new GeoPoint((int) (latitude * 1E6),
(int) (longitude * 1E6));
// Map overlay item
overlayitem = new OverlayItem(geoPoint,"0",place.reference);
itemizedOverlay.addOverlay(overlayitem);
// calculating map boundary area
minLat = (int) Math.min(geoPoint.getLatitudeE6(), minLat);
minLong = (int) Math.min(geoPoint.getLongitudeE6(), minLong);
maxLat = (int) Math.max(geoPoint.getLatitudeE6(), maxLat);
maxLong = (int) Math.max(geoPoint.getLongitudeE6(), maxLong);
}
mapOverlays.add(itemizedOverlay);
// showing all overlay items
itemizedOverlay.populateNow();
}
// Adjusting the zoom level so that you can see all the markers on map
mapView.getController().zoomToSpan(Math.abs(minLat - maxLat), Math.abs(minLong - maxLong));
MapController controller = mapView.getController();
controller.setZoom(15);
// Showing the center of the map
mc.animateTo(new GeoPoint((maxLat + minLat)/2, (maxLong + minLong)/2));
mapView.postInvalidate();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
처럼 보인다?
난 당신처럼 같은 문제가 글을 많이 읽었지만 that..i 생각에 대해 나는 어떤 솔루션을 보지 못했다 당신은 Google지도 API v2를 사용하여 새로운 프로젝트를 만들어야합니다 ..! – TheFlash