Friday 15 April 2011

java - how to get the longitude and latitude value of the marker in google map v2 -



java - how to get the longitude and latitude value of the marker in google map v2 -

i working in google map v2. added 1 marker on map. not beingness able location marker. have search lot in google didn't proper answer. want toast longitude , latitude value of marker.can suggest me anything?

my code:

double mylongitudey,mylatitudey; string latilongi; imageview iv; button manual,proceed; googlemap map; latlng mylat ; string latlong; marker mymarker,marker; boolean markerclicked; double mylatitudeyd,mylongitudeyd; string addstringaa; @override protected void oncreate(bundle savedinstancestate) { locationmanager lm; lm= (locationmanager) getsystemservice(context.location_service); toast.maketext(this,"please select destination long click", toast.length_long).show(); latlng mylat; final googlemap map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); map.setonmarkerdraglistener(this); map.settrafficenabled(true); map.setmylocationenabled(true); map.setonmarkerdraglistener(this); map.setonmylocationbuttonclicklistener(this); map.animatecamera(cameraupdatefactory.zoomto(15)); // map.setonmylocationbuttonclicklistener(this); map.movecamera(cameraupdatefactory.newlatlngzoom(mylat, 13)); map.addmarker(new markeroptions().position(mylat).title("you here")); markerclicked=false; //onmylocationbuttonclick(); map.setonmaplongclicklistener(new googlemap.onmaplongclicklistener() { @override public void onmaplongclick(latlng arg0) { // todo auto-generated method stub if(markerclicked==false) { mymarker = map.addmarker(new markeroptions().position(arg0).title("your destination").draggable(true)); markerclicked=true; }else{ toast.maketext(getapplicationcontext(), "marker aready set..!", toast.length_long).show(); } } }); map.setonmylocationchangelistener(new googlemap.onmylocationchangelistener() { latlng mylatlong; @override public void onmylocationchange(location arg0) { // todo auto-generated method stub mylongitudey = arg0.getlongitude(); mylatitudey = arg0.getlatitude(); mylatlong = new latlng(arg0.getlatitude(), arg0.getlongitude()); //sourcepoint=string.format(" ",mylat); marker= map.addmarker(new markeroptions().position(mylatlong).title("your destination")); // map.movecamera(cameraupdatefactory.newlatlngzoom(mylat,1)); map.movecamera(cameraupdatefactory.newlatlngzoom(mylatlong, 14)); } });

calling marker.getposition() homecoming latlng object stores latitude , longitude.

marker marker = <your initialization>; latlng latlng = marker.getposition(); double latitude = latlng.latitude; double longitude = latlng.longitude;

java android eclipse google-maps

No comments:

Post a Comment