0

ブラウザーで Google マップにアクセスすると、国名を入力すると、その国にフォーカスしたマップが表示されます。これをMapViewで取得することは可能ですか? 場所が利用できない場合、MapView で最初にユーザーの国に焦点を合わせたいと思います。

編集:これが私がこれまでに持っているものです:

private MapView mvClear;
private MyLocationOverlay compass;
private MapController controller;

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_clear_map);

   mvClear = (MapView) findViewById(R.id.mvClear);
   mvClear.setBuiltInZoomControls(true);

   TouchOverlay touchOverlay = new TouchOverlay();
   List<Overlay> overlays = mvClear.getOverlays();
   overlays.add(touchOverlay);

   compass = new MyLocationOverlay(this, mvClear);
   overlays.add(compass);

   controller = mvClear.getController();
   controller.setZoom(8);

   Geocoder coder = new Geocoder(this);
   try {
       List<Address> address = coder.getFromLocationName(Locale.getDefault().getCountry(), 1);
       int lat = (int) address.get(0).getLatitude();
       int lon = (int) address.get(0).getLongitude();
       GeoPoint point = new GeoPoint(lat, lon);
       controller.setCenter(point);
   } catch (IOException e) {
       e.printStackTrace();
   }
}

焦点が合っていません。

4

1 に答える 1

0

私が見つけた最善の解決策は、アプリがローカライズされている場合に「翻訳」できるように、デフォルトの中心点を文字列リソースとして保存することでした。とりあえず以上です..

于 2013-02-05T17:52:56.767 に答える