Created
December 29, 2012 11:21
-
-
Save galex/4406271 to your computer and use it in GitHub Desktop.
Part of my map fragment, on Load finished to put markers on the map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (getMap() != null) { | |
getMap().clear(); | |
markerPlaces = new HashMap<Marker, Place>(); | |
for (Category category : data) { | |
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(category.getType().getIconResId()); | |
for (Place place : category.getPlaces()) { | |
Marker marker = getMap().addMarker(new MarkerOptions().position(new LatLng(place.getLat(), place.getLng())).title(place.getTitle()).snippet(place.getDescription()).icon(icon)); | |
markerPlaces.put(marker, place); | |
getMap().setOnInfoWindowClickListener(new OnInfoWindowClickListener() { | |
@Override | |
public void onInfoWindowClick(Marker marker) { | |
Place place = markerPlaces.get(marker); | |
PlaceDetailActivity.startActivity(getSherlockActivity(), place); | |
} | |
}); | |
} | |
} | |
getMap().setInfoWindowAdapter(new PlaceInfoWindowAdapter(getSherlockActivity(), markerPlaces)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment