Então, mais de uma semana que mandei perguntando se alguém entendi da API do Google Place... é que fiquei tentando descobrir como realmente funciona e acabei solucionando alguns problemas, mas outros apareceram... queria mais um "pulo do gato" pra entender realmente como essa api do google place funciona...
private void convertJSONtoArray(String rawJSON){
try {
JSONObject completeJSONObj = new JSONObject(rawJSON);
String json = completeJSONObj.toString();
Log.d(TAG,json);
JSONArray results = completeJSONObj.getJSONArray("results");
for (int i = 0; i < results.length(); i++) {
JSONObject jsonObject = results.getJSONObject(i);
String name = jsonObject.getString("name");
JSONObject geometry = jsonObject.getJSONObject("geometry");
JSONObject location = geometry.getJSONObject("location");
double lat = location.getDouble("lat");
double lng = location.getDouble("lng");
int latINT = (int) (lat*1E6);
int lngINT = (int) (lng*1E6);
ArrayList<GeoPoint> locais = new ArrayList<GeoPoint>();
locais.add(new GeoPoint(latINT, lngINT));
LocationOverlay myOverlay =
new LocationOverlay(getResources().getDrawable(R.drawable.ic_launcher));
myOverlay.setItems(locais);
mapView.getOverlays().add(myOverlay);
}
} catch (JSONException e) {
Log.d(TAG,"JSON parsing error - fix it:" + e.getMessage());
}
Como podem reparar eu instancio uma classe chamada LocationOverlay que é extendida pelo ItemizedOverlay<OverlayItem> , vou coloca-la mais abaixo depois...
public class LocationOverlay extends ItemizedOverlay<OverlayItem>{
private List<GeoPoint> mItems;
final String TAG = getClass().getSimpleName();
public LocationOverlay(Drawable marker) {
super(boundCenterBottom(marker));
}
public void setItems(ArrayList<GeoPoint>items){
mItems = items;
populate();
}
@Override
protected OverlayItem createItem(int i) {
return new OverlayItem(mItems.get(i),null,null);
}
@Override
public int size() {
return mItems.size();
}
@Override
public boolean onTap(int i) {
return true;
}
}
Opa, qual a dúvida?--On Mon, Jun 18, 2012 at 8:00 PM, Ricardo Cardoso <rick.duk@gmail.com> wrote:
Alguém ja trabalhou com a API do Google Place??Segue o link da doc.Abraços
Aquele Abraço,
Ricardo Araujo






0 comentários:
Postar um comentário