Maps API v2 with different marker actions

前端 未结 4 561
我在风中等你
我在风中等你 2020-12-24 14:37

I\'m trying to port my application to the new Google Maps API v2, but i\'m having trouble when interacting with markers.

My context: I have a map showing buses and

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 15:09

    Ok here is a solution which I decided to use and AFAIK should work for any situation:

    private HashMap markers= new HashMap();
    
    
    MyModel item = ...
    MarkerOptions markerOptions = ...
    markers.put(mMap.addMarker(markerOptions).getId(), item);
    
    
    
    @Override
    public void onInfoWindowClick(Marker marker) {
       MyModel mapItem = (MyModel) markers.get(marker.getId());.
       ...
    }
    

提交回复
热议问题