android - fetch and display the JSON data in Marker info window extracting the place type of current location -
i have 2 auto complete find route completed that.now have route 2 locations.i have origin , destination marker.in set info window display latitude,longitude,locality,sub locality,admin area.i have displayed lat , lan.now fetch json data , display in info window.i have parse data doesnt know how display in info window.suggest solutions..
googlemap.setinfowindowadapter(new googlemap.infowindowadapter() { // use default infowindow frame public view getinfowindow(marker arg0) { return null; } // defines contents of infowindow public view getinfocontents(marker arg0) { // getting view layout file info_window_layout view v = getlayoutinflater().inflate(r.layout.info_window, null); // getting position marker latlng latlng = arg0.getposition(); // getting reference textview set latitude textview tvlat = (textview) v.findviewbyid(r.id.tv_lat); // getting reference textview set longitude textview tvlng = (textview) v.findviewbyid(r.id.tv_lng); textview type=(textview)v.findviewbyid(r.id.type); // setting latitude tvlat.settext("latitude:" + latlng.latitude); // setting longitude tvlng.settext("longitude:" + latlng.longitude); type.settext("locality"+""); // returning view containing infowindow contents return v; } }); public void ondirectionfinderstart() { progressdialog = progressdialog.show(this, "please wait.", "finding direction..!", true); if (originmarkers != null) { (marker marker : originmarkers) { marker.remove(); marker.showinfowindow(); } } if (destinationmarkers != null) { (marker marker : destinationmarkers) { marker.remove(); marker.showinfowindow(); } } if (polylinepaths != null) { (polyline polyline : polylinepaths) { polyline.remove(); } } } private class getlocationtask extends asynctask<void, void, void> { protected void doinbackground(void... arg0) { // creating service handler class instance servicehandler sh = new servicehandler(); // making request url , getting response string jsonstr = sh.makeservicecall(url, servicehandler.get); log.d("response: ", "> " + jsonstr); if (jsonstr != null) { try { jsonobject jsonobj = new jsonobject(jsonstr); jsonarray addrcomp = jsonobj.getjsonarray("results"); (int = 0; < addrcomp.length(); i++){ jsonobject ad=new jsonobject(); jsonarray addr = ad.getjsonarray("address_components"); (i = 0; < addr.length(); i++){ jsonobject ty=new jsonobject(); jsonarray typ=ty.getjsonarray("types"); (i = 0; < typ.length(); i++){ jsonobject c = typ.getjsonobject(i); string locality=c.getstring("locality"); string political=c.getstring("political"); string sublocality=c.getstring("sublocality"); string adminarea=c.getstring("administrative_area_level_1"); /*hashmap<string, string> local = new hashmap<>(); local.put("locality",locality); local.put("administrative_area_level_1",adminarea); local.put("sublocality",sublocality); local.put("political",political); list.add(local);*/ } } } } catch (jsonexception e) { e.printstacktrace(); } } else { log.e("servicehandler", "couldn't data url"); } return null; } }
you can use https://developers.google.com/maps/documentation/android-api/infowindows
or http://androidfreakers.blogspot.in/2013/08/display-custom-info-window-with.html achieve requirements. need create custom layout , set info adapter.
Comments
Post a Comment