Как приписать имена к точкам?

Рейтинг: 0Ответов: 1Опубликовано: 26.03.2015

В последнее время просто сыплю вопросами, за ответы на которые большое спасибо. )

Еще один вопрос:

Есть код:

GeoPoint currentLocation = new GeoPoint(55.895859, 37.719324);
GeoPoint locations[] = new GeoPoint[] {
            new GeoPoint(55.895859, 37.719324),
            new GeoPoint(55.881231, 37.636800),
            new GeoPoint(55.865430, 37.648020)
    };

GeoPoint nearest = GeoPoint.getNearestLocation(currentLocation,
            Arrays.asList(locations));

public void onClick(View view){
        TextView helloTextView = (TextView)findViewById(R.id.station_name);
        helloTextView.setText(nearest.toString());
    }

Вопрос: как сделать так, чтобы выводились имена этих точек (как приписать их в коде)?

Ответы

▲ 1
Map<GeoPoint, String> geoPointsMap = new HashMap<GeoPoint, String>();
geoPointsMap.put(new GeoPoint(55.895859, 37.719324), "Имя для точки 1");
geoPointsMap.put(new GeoPoint(55.881231, 37.636800), "Имя для точки 2");
geoPointsMap.put(new GeoPoint(55.865430, 37.648020), "Имя для точки 3");

...

String name = geoPointsMap.get(locations[0]);
String nameForNearest = geoPointsMap.get(nearest);