但是我无法单独选择它们
如何通过触摸标记分别选择每个标记并获取其详细信息。 json
array
下方的此函数中的A使用0-19(20)个元素。
我不知道如何使用它们分别选择每个标记。
private void parseLocationResult(final JSONObject result) {
String id, place_id, placeName = null, reference, icon, vicinity = null;
JSONArray rev;
double latitude;
double longitude;
try {
final JSONArray jsonArray = result.getJSONArray(RESULTS);//JavaScript Object Notation
if (result.getString(STATUS).equalsIgnoreCase(OK)) {
mMap.clear();
for (int i = 0; i < jsonArray.length(); i++) {
final JSONObject place = jsonArray.getJSONObject(i);
id = place.getString(SUPERMARKET_ID);
place_id = place.getString(PLACE_ID);
if (!place.isNull(NAME)) {
placeName = place.getString(NAME);
}
if (!place.isNull(VICINITY)) {
vicinity = place.getString(VICINITY);
}
latitude = place.getJSONObject(GEOMETRY).getJSONObject(LOCATION)
.getDouble(LATITUDE);
longitude = place.getJSONObject(GEOMETRY).getJSONObject(LOCATION)
.getDouble(LONGITUDE);
reference = place.getString(REFERENCE);
icon = place.getString(ICON);
MarkerOptions markerOptions = new MarkerOptions();
final LatLng latLng = new LatLng(latitude, longitude);
markerOptions
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bluemarker))
.position(latLng);
markerOptions.title(placeName + " : " + vicinity);
mMap.addMarker(markerOptions);
}
Toast.makeText(getBaseContext(), jsonArray.length() + " found!",
Toast.LENGTH_LONG).show();
} else if (result.getString(STATUS).equalsIgnoreCase(ZERO_RESULTS)) {
Toast.makeText(getBaseContext(), "Not found in 5KM radius!!!",
Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
Log.e(TAG, "parseLocationResult: Error=" + e.getMessage());
}
}
答案 0 :(得分:0)
实施GoogleMap.OnMarkerClickListener
并覆盖onMarkerClick
以检测点击标记
@Override
public boolean onMarkerClick(Marker marker) {
// on marker clicked
if (marker.equals(this.marker)) {
// on specific marker clicked
}
return false;
}