1
Google지도 지향적 인 Android 프로젝트로 작업 중입니다.이 클래스에서 문제가 발생했습니다. 특정 오버레이를 터치하면 가장 가까운 위치를 표시하기 위해 특정 오버레이를 사용했습니다. alert-box에는 이름과 참조가 포함되어 있습니다. 이제는 getsnipet() 메서드를 사용하여 참조를 검색합니다. 이제 알림 대화 상자를 표시하고 싶지는 않지만 참조를 가져올 수없는 경우 아무도이 문제를 해결할 수 없습니다. 오류 여기 난 당신이 getsnippet()
사용에 정확이 경우 '참조'뜻 '설명'으로 생각 ...선택한 오버레이 값을 개별적으로 가져올 수 없습니다.
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;
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();
p_u_name=i.getStringExtra("p_u_name");
reference = (Place) i.getSerializableExtra("place_reference");
i.putExtra("p_u_name",p_u_name);
// Users current geo location
String user_latitude = i.getStringExtra("user_latitude");
String user_longitude = i.getStringExtra("user_longitude");
System.out.println("sarath"+user_latitude + 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 marker icon
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));
String s = place.formatted_address;
String p = place.formatted_phone_number;
String n = s;
System.out.println("sarath"+s);
// Map overlay item
//Here it passes the selected overlay name and reference to the alerdialog box
overlayitem = new OverlayItem(geoPoint,place.name,place.reference);
i.putExtra("place_reference", place.reference);
// System.out.println("this is mapactivity and reference is:"+ab);
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));
// Showing the center of the map
mc.animateTo(new GeoPoint((maxLat + minLat)/2, (maxLong + minLong)/2));
mapView.postInvalidate();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
이것은 Google Maps API V3에 관한 것이 아닙니다. (태그 제거) – Marcelo
잘 디버그이 문제 –