0

前のアクティビティのボタンをクリックして特定の都市の地図を表示するにはどうすればよいですか..たとえば: アクティビティ 1 で、edittext に New York と入力してボタンをクリックすると、地図とニューヨーク市へのポイントを含むアクティビティ 2 が開きました...私はまた、ニューヨークの観光名所をさまざまなマーカーで表示したいと考えています..

場所を更新しませんが、近くの場所を示す地図を作成しました.. :(

4

2 に答える 2

0

ここでは、1 つの質問で多くの質問をしています。

住所で都市を見つけて地図上に表示するには、Geocoderこのチュートリアルで確認できる都市座標を提供するを作成する必要があります。

http://wptrafficanalyzer.in/blog/android-geocoding-showing-user-input-location-on-google-map-android-api-v2/

Geocoder サービスにアクセスするために表示される AsyncTask コード スニペットを次に示します。

// An AsyncTask class for accessing the GeoCoding Web Service
private class GeocoderTask extends AsyncTask<String, Void, List<Address>>{

    @Override
    protected List<Address> doInBackground(String... locationName) {
        // Creating an instance of Geocoder class
        Geocoder geocoder = new Geocoder(getBaseContext());
        List<Address> addresses = null;

        try {
            // Getting a maximum of 3 Address that matches the input text
            addresses = geocoder.getFromLocationName(locationName[0], 3);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return addresses;
    }

    @Override
    protected void onPostExecute(List<Address> addresses) {

        if(addresses==null || addresses.size()==0){
            Toast.makeText(getBaseContext(), "No Location found", Toast.LENGTH_SHORT).show();
        }

        // Clears all the existing markers on the map
        googleMap.clear();

        // Adding Markers on Google Map for each matching address
        for(int i=0;i<addresses.size();i++){

            Address address = (Address) addresses.get(i);

            // Creating an instance of GeoPoint, to display in Google Map
            latLng = new LatLng(address.getLatitude(), address.getLongitude());

            String addressText = String.format("%s, %s",
            address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "",
            address.getCountryName());

            markerOptions = new MarkerOptions();
            markerOptions.position(latLng);
            markerOptions.title(addressText);

            googleMap.addMarker(markerOptions);

            // Locate the first location
            if(i==0)
                googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
        }
    }
}

ツーリストのアトラクションについては、そのような情報を提供するある種のサービスにクエリを実行し、それを解析してマップにも表示する必要があります。

于 2013-07-04T16:04:55.760 に答える