android - Google Maps Api V2 draw circle around current position -


im working google maps api v2 on android project, need able draw circle around users current position , display markers points of interest within radious around users current position.

im struggling small marker denotes users current position can draw circle around it.

this code far.

//set map , display users current position.     mapfragment mapfragment = (mapfragment) getfragmentmanager()             .findfragmentbyid(r.id.nearbymapsearch);     mapfragment.getmapasync(this);      final googlemap map = (((mapfragment) getfragmentmanager().findfragmentbyid(r.id.nearbymapsearch)).getmap());     map.setmylocationenabled(true);      //zoom users location     geolocationhandler geohandler = new geolocationhandler(getactivity().getapplicationcontext());     log.i("search fragment", "" + geohandler.getcurrentlatitude() + " , " + geohandler.getcurrentlongitude());     latlng loc = new latlng(geohandler.getcurrentlatitude(), geohandler.getcurrentlongitude());      //begin animating camera.     map.animatecamera(cameraupdatefactory.newlatlngzoom(             new latlng(loc.latitude, loc.longitude), 13));      //instantiate new camera position     cameraposition cameraposition = new cameraposition.builder()             .target(new latlng(loc.latitude, loc.longitude))             .zoom(3)             .bearing(0)             .tilt(0)             .build();     map.animatecamera(cameraupdatefactory.newcameraposition(cameraposition)); 

any appreciated thanks.

circle circle = map.addcircle(new circleoptions()      .center(new latlng(loc.latitude, loc.longitude))      .radius(1000)      .strokecolor(color.red)      .fillcolor(color.blue)); 

more info https://developers.google.com/android/reference/com/google/android/gms/maps/model/circle

you should subscribe updates of user location , reset circle center with

circle.setcenter(newlocation); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -