Created
April 21, 2016 13:28
-
-
Save here-devblog-gists/7d221a30bf93039e39ecd9c1b796c2a2 to your computer and use it in GitHub Desktop.
This file contains 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
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