java - Async and Google Maps -


here:async , listview android

i asked async , listview. have problem async , maps. want set marker json returns async. unfortunately, set default values , not want to. can help

public class markerinfo extends fragmentactivity implements onmapreadycallback { private googlemap mmap; private latlng sydney; private string longituide; private string latitude;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_marker_info);     supportmapfragment mapfragment = (supportmapfragment) getsupportfragmentmanager()             .findfragmentbyid(r.id.map);     mapfragment.getmapasync(this);      bundle bundle_list = getintent().getextras();     final string name_item = bundle_list.getstring("name");      jsonobject tosend = new jsonobject();     try {         tosend.put("action", "getallmarkers");     } catch (jsonexception e) {         e.printstacktrace();     }      jsontransmitter asynctask = (jsontransmitter) new jsontransmitter(new jsontransmitter.asyncresponse() {         @override         public void processfinish(string output) {             try {                 jsonarray pages = new jsonarray(output);                 (int = 0; < pages.length(); ++i) {                     jsonobject rec = pages.getjsonobject(i);                     string name_task = rec.getstring("nazwa");                     latitude = rec.getstring("latitude");                     longituide = rec.getstring("longitude");                     mmap.addmarker(new markeroptions().position(new latlng(double.parsedouble(longituide), double.parsedouble(latitude))));                 }             } catch (jsonexception e) {                 e.printstacktrace();             }         }      }).execute(tosend); }  public void onmapready(googlemap googlemap) {     mmap = googlemap; } 

}

execute async map dependent operation (adding markers), after google map ready.

jsontransmitter asynctask; googlemap mmap;  @override protected void oncreate(bundle savedinstancestate) {     ...      mapfragment.getmapasync(this);      asynctask = (jsontransmitter) new jsontransmitter(new jsontransmitter.asyncresponse() {         @override         public void processfinish(string output) {             try {                 jsonarray pages = new jsonarray(output);                 (int = 0; < pages.length(); ++i) {                     jsonobject rec = pages.getjsonobject(i);                     string name_task = rec.getstring("nazwa");                     latitude = rec.getstring("latitude");                     longituide = rec.getstring("longitude");                     mmap.addmarker(new markeroptions().position(                        new latlng(double.parsedouble(longituide), double.parsedouble(latitude))));                 }             } catch (jsonexception e) {                 e.printstacktrace();             }         }     }); }  public void onmapready(googlemap googlemap) {     mmap = googlemap;      jsonobject tosend = new jsonobject();      try {         tosend.put("action", "getallmarkers");     } catch (jsonexception e) {         e.printstacktrace();     }      asynctask.execute(tosend); } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -