android - Cant get Geopoints to add to google map due to; Couldn't get connection factory client -
i getting error while try plot multiple geopoint locations onto google map. reading latitude , longitude mysql database through php , json. have looked @ main examples, such couldn't connection factory client, couldn't connection factory client - fighting google maps, android mapactivity : couldn't connection factory client.
i can confirm not invalid api key have generated 2 different keys , returned same error. not api level problem either, tried run application on api level 17 , on level 8 , still no joy. when run code displays map no problem , gets exception toast message of "error displaying contents"
here mapview.java code:
import java.util.arraylist; import java.util.list; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.namevaluepair; import org.apache.http.client.httpclient; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.defaulthttpclient; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; import android.graphics.drawable.drawable; import android.net.parseexception; import android.os.bundle; import android.util.log; import android.widget.toast; import java.io.bufferedreader; import java.io.inputstream; import java.io.inputstreamreader; import com.google.android.maps.geopoint; import com.google.android.maps.mapactivity; import com.google.android.maps.mapcontroller; import com.google.android.maps.mapview; import com.google.android.maps.overlay; import com.google.android.maps.overlayitem; public class mapview extends mapactivity { //protected mapview mapview; jsonarray jarray; string result=null; inputstream is=null; stringbuilder sb=null; double lat; double lng; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.mapview); mapview mapview = (mapview) findviewbyid(r.id.mapview); mapview.setbuiltinzoomcontrols(true); //arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); try { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://10.0.2.2/displaymarkers.php"); //httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); } catch(exception e) { log.e("log_tag", "error in http connection"+e.tostring()); } try{ jarray = new jsonarray("$json_output[]"); jsonobject json_data = null; for(int = 0; < jarray.length(); i++) { json_data = jarray.getjsonobject(i); lat=json_data.getdouble("lat"); lng=json_data.getdouble("lng"); geopoint point = new geopoint((int)(lat * 1e6), (int)(lng * 1e6)); overlayitem overlayitem = new overlayitem(point, "text", null); list<overlay> mapoverlays = mapview.getoverlays(); drawable drawable = this.getresources().getdrawable(r.drawable.marker); myitemizedoverlay itemizedoverlay = new myitemizedoverlay(drawable, this); mapcontroller mapcontroller = mapview.getcontroller(); //mapcontroller.animateto(point); mapcontroller.setzoom(8); itemizedoverlay.addoverlay(overlayitem); mapoverlays.add(itemizedoverlay); } } catch(jsonexception e1) { toast.maketext(getbasecontext(), "error displaying contents" ,toast.length_long).show(); } catch (parseexception e1) { e1.printstacktrace(); } } @override protected boolean isroutedisplayed() { return false; } }
this itemizedoverlay.java code:
import java.util.arraylist; import android.app.alertdialog; import android.content.context; import android.graphics.drawable.drawable; import com.google.android.maps.overlayitem; import com.google.android.maps.itemizedoverlay; public class myitemizedoverlay extends itemizedoverlay { private arraylist<overlayitem> mapoverlays = new arraylist<overlayitem>(); private context mcontext; public myitemizedoverlay(drawable marker, context context) { super(boundcenterbottom(marker)); mcontext = context; } public void addoverlay(overlayitem overlay) { mapoverlays.add(overlay); this.populate(); } @override protected overlayitem createitem(int i) { return mapoverlays.get(i); } @override public int size() { return mapoverlays.size(); } @override protected boolean ontap(int index) { overlayitem item = mapoverlays.get(index); alertdialog.builder dialog = new alertdialog.builder(mcontext); dialog.settitle(item.gettitle()); dialog.setmessage(item.getsnippet()); dialog.show(); return true; } }
i appreciate get, in advance.
if have generated these keys recently, not results, because api v1 deprecated , won't work.
you may want switch maps api v2: https://developers.google.com/maps/documentation/android/
don't try use old code, because new api doesn't share code api v1.
Comments
Post a Comment