i have a question, i have 2 json files, the first one is for categories and
the second is to generate markers and put them in the map, the first screen
of my app show the categories on a listview, and when i click one of the
categories it should display the markers according to the category selected
on the map, I have no problem displaying the map or reading json
Example json categories
{ "categories":[ { "id":"01",
>
"categoria":"Restaurante" }
>
] }
>
Example json places
{ "places":[ { "id":"01", "lat":"20.583566571214778",
> "long":"-100.37047419121245", "dist":"100m", "star":"1", "icon":"03",
> "name":"Restaurante San Pedro", "cat":"Restaurante", "sched":"9:00 -
> 23:00", "text":"Una gran seleccion de platillos para su deleite." } ] }
>
The problem, is that it won’t display the markers, I am using an if to
compare that the category selected is the same of any category business in
places json, and if it’s the same it display the marker, I use a toast to
see the result and It’s the same, I don’t know why it won’t execute the if
sentence instead of else
> if (cat == recuperamos_variable_cat) {
>
> LatLng lugares = new LatLng(dlatitud, dlongitud);
>
Marker ubicacion2 = mapa.addMarker(new MarkerOptions()
>
.position(lugares)
>
.title(name)
>
.snippet(text));
>
Toast mensaje2 = Toast.makeText(getApplicationContext(),
>
cat + recuperamos_variable_cat, Toast.LENGTH_SHORT);
>
mensaje2.show();
>
> } else {
>
> Toast mensaje2 = Toast.makeText(getApplicationContext(),
>
"No hay coincidencias", Toast.LENGTH_SHORT);
>
mensaje2.show();
>
}
>
I put the rest of the code
> //recover the value of the category selected
>
final String recuperamos_variable_id = getIntent().getStringExtra("TAG_ID");
>
final String recuperamos_variable_cat =
> getIntent().getStringExtra("TAG_CAT");
>
> // Hashmap for ListView
>
ArrayList<HashMap<String, String>> placesList = new
> ArrayList<HashMap<String, String>>();
>
// Creating JSON Parser instance
>
JSONParser jParser = new JSONParser();
>
// getting JSON string from URL
>
JSONObject json = jParser.getJSONFromUrl(url);
>
try {
>
// Getting Array of Contacts
>
places = json.getJSONArray(TAG_PLACES);
>
> // looping through All Contacts
>
> for(int i = 0; i < places.length(); i++){
>
JSONObject c = places.getJSONObject(i);
>
> // Storing each json item in variable
>
String id = c.getString(TAG_ID);
>
String lat = c.getString(TAG_LAT);
>
String lon = c.getString(TAG_LONG);
>
String dist = c.getString(TAG_DIST);
>
String star = c.getString(TAG_STAR);
>
String name = c.getString(TAG_NAME);
>
String cat = c.getString(TAG_CAT);
>
String icon = c.getString(TAG_ICON);
>
String sched = c.getString(TAG_SCHED);
>
String text = c.getString(TAG_TEXT);
>
> double dlatitud = Double.parseDouble(lat);//Convertimos valores a double
>
double dlongitud = Double.parseDouble(lon);
>
>
> if (cat == recuperamos_variable_cat) { LatLng lugares = new
> LatLng(dlatitud, dlongitud);
>
Marker ubicacion2 = mapa.addMarker(new MarkerOptions()
>
.position(lugares)
>
.title(name)
>
.snippet(text));
>
Toast mensaje2 = Toast.makeText(getApplicationContext(),
>
cat + recuperamos_variable_cat, Toast.LENGTH_SHORT);
>
mensaje2.show();
>
> } else {
>
Toast mensaje2 = Toast.makeText(getApplicationContext(),
>
"No hay coincidencias", Toast.LENGTH_SHORT);
>
mensaje2.show();
>
}
>
}
>
} catch (JSONException e) {
>
e.printStackTrace();
>
}
>
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.