Skip to content

Instantly share code, notes, and snippets.

@here-devblog-gists
Created April 21, 2016 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save here-devblog-gists/7d221a30bf93039e39ecd9c1b796c2a2 to your computer and use it in GitHub Desktop.
Save here-devblog-gists/7d221a30bf93039e39ecd9c1b796c2a2 to your computer and use it in GitHub Desktop.
class SearchRequestListener implements ResultListener<DiscoveryResultPage> {
@Override
public void onCompleted(DiscoveryResultPage data, ErrorCode error) {
if (error != ErrorCode.NONE) {
// Handle error
} else {
// results can be of different types
// we are only interested in PlaceLinks
List<PlaceLink> results = data.getPlaceLinks();
if (results.size() > 0) {
for (PlaceLink result : results) {
// get all results that are far away enough to be a good candidate
if (result.getDistance() < range && result.getDistance() > (range * 0.7f)) {
GeoCoordinate c = result.getPosition();
com.here.android.mpa.common.Image img =
new com.here.android.mpa.common.Image();
try {
img.setImageAsset("pin.png");
} catch (IOException e) {
// handle exception
}
MapMarker marker = new MapMarker(c, img);
marker.setTitle(result.getTitle());
// using a container to group the markers
placesContainer.addMapObject(marker);
}
}
} else {
// handle empty result case
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment