Issue
I am able to get nearby places but, how do i draw the places in my mapView? do i need to get the lat and lng and draw them myself (ItemizedOverlay and so on)? if so, what should i do with the icon? because i cannot use drawable, its just an URL.
I use this method to retrieve a list of places:
public void performSearch() throws IOException {
HttpRequestFactory httpRequestFactory = createRequestFactory(transport);
HttpRequest request = httpRequestFactory.buildGetRequest(new GenericUrl(PLACES_SEARCH_URL));
request.getUrl().put("key", API_KEY);
request.getUrl().put("location", lat + "," + lng);
request.getUrl().put("radius", 100);
request.getUrl().put("types", "pharmacy|hospital");
request.getUrl().put("sensor", "false");
PlacesList places = request.execute().parseAs(PlacesList.class);
for (Place place : places.results) {
System.out.println(place.name + " - " + place.icon);
}
}
public static HttpRequestFactory createRequestFactory(final HttpTransport transport) {
return transport.createRequestFactory(new HttpRequestInitializer() {
public void initialize(HttpRequest request) {
GoogleHeaders headers = new GoogleHeaders();
headers.setApplicationName("The Day After");
request.setHeaders(headers);
JsonHttpParser parser = new JsonHttpParser(new JacksonFactory());
request.addParser(parser);
}
});
}
Thanks in advance
Solution
Android's Map API is quite lacking. You need to provide your own drawables for the overlays. You can extract them from the google maps app if you feel lazy ;) For this just locate the maps apk inside /System/app/ from a phone file browser and copy it to the sd card. Then on the computer change the extension from apk to zip and you'll be able to extract the nice overlay icons.
Although I must say that you should use them as a guidelne to create your own since these are IP from Google.
Hope it helps.
Answered By - pablisco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.