我有一个地址,想在 Google 地图上显示该地址。地图显示但未指向该特定地址。这是我的代码。我收到此错误:couldn't get connection factory client
。
private MapController mc;
private MapView mapView;
GeoPoint p;
private MyOverlays mapOverlay;
mapView = (MapView) findViewById(R.id.myMapView);
mapView.setBuiltInZoomControls(true);
Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocationName(loc, 5);
if (addresses.size() > 0) {
p = new GeoPoint(
(int) (addresses.get(0).getLatitude() * 1E6),
(int) (addresses.get(0).getLongitude() * 1E6));
mc.animateTo(p);
mapView.invalidate();
}
} catch (IOException e) {
e.printStackTrace();
}
if (p != null) {
Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
mapOverlay = new MyOverlays(drawable, this);
OverlayItem overlayitem = new OverlayItem(p, "", "");
mapOverlay.addOverlay(overlayitem);
mapView.getOverlays().add(mapOverlay);
this.mc = this.mapView.getController();
this.mc.setCenter(this.p);
this.mc.setZoom(16);
}
// LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, (LocationListener) this);