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