0
我在地图上添加了折线,并启用了setClickable(true)
但是当我从Clickable
使用不起作用时?Android- onPolylineClick不起作用?
private class ParserTask extends AsyncTask<String, Integer, List<List<HashMap<String,String>>>> {
@Override
protected List<List<HashMap<String, String>>> doInBackground(String... jsonData) {
JSONObject jObject;
List<List<HashMap<String, String>>> routes = null;
try{
jObject = new JSONObject(jsonData[0]);
parser = new DirectionsJSONParser();
// Starts parsing data
routes = parser.parse(jObject);
}catch(Exception e){
e.printStackTrace();
}
return routes;
}
@Override
protected void onPostExecute(List<List<HashMap<String, String>>> result) {
ArrayList<LatLng> points = null;
PolylineOptions lineOptions = null;
MarkerOptions markerOptions = new MarkerOptions();
// Traversing through all the routes
for(int i=0;i<result.size();i++){
points = new ArrayList<LatLng>();
lineOptions = new PolylineOptions();
String color = colors[i % colors.length];
// Fetching i-th route
List<HashMap<String, String>> path = result.get(i);
// Fetching all the points in i-th route
for(int j=0;j<path.size();j++){
HashMap<String,String> point = path.get(j);
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
// Adding all the points in the route to LineOptions
lineOptions.addAll(points);
lineOptions.width(15);
lineOptions.clickable(true);
lineOptions.color(Color.parseColor(color));
// Drawing polyline in the Google Map for the i-th route
Polyline polyline = mMap.addPolyline(lineOptions);
polyline.setClickable(true);
}
}
}
然后我implements GoogleMap.OnPolylineClickListener
:
@Override
public void onPolylineClick(Polyline polyline) {
Log.i("LOG","OK");
}
我看不到任何log
。