java - Draw five transparent circumcircles on the Google Map v2 -


i have started working google map v2 , figured out lot of things have been changed. using google map v1 using concept of mapview.

i trying create five transparent circumcircles center current location. below code, using google map v1 draw circle , working fine me. trying draw same circle have drawn in below code on google map v2. cannot use mapview here using googlemap object here. can me draw circle on google map v2 center current location

@override public void onlocationchanged(location location) {         if (location != null) {             geopoint point = new geopoint(                     (int) (location.getlatitude() * 1e6),                     (int) (location.getlongitude() * 1e6));              // create latlng object current location             latlng latlng = new latlng(location.getlatitude(),  location.getlongitude());              // show location on google map             googlemap.movecamera(cameraupdatefactory.newlatlng(latlng));              // zoom in google map             googlemap.animatecamera(cameraupdatefactory.zoomto(15));          //   below code google map v1 draw circle on map            //   if (mapoverlay == null) {         //   mapoverlay = new mapoverlay(this, r.drawable.mark_blue);          //   list<overlay> listofoverlays = mapview.getoverlays();         //   listofoverlays.add(mapoverlay);         //   }          //   mapoverlay.setpointtodraw(point);         //   mapview.invalidate();         } } 

a simple class extends overlay , draw circle on google map v1

class mapoverlay extends overlay {     private geopoint pointtodraw;     int[] imagenames = new int[6];      // cached point on screen refilled on     // every draw     private point mscreenpoints;      // cached decoded bitmap drawn each time     private bitmap mbitmap;      // cached paint     private paint mcirclepaint;      public mapoverlay(proximitylocationlistener gpslocationlistener,             int currentuser) {         imagenames[0] = currentuser;         imagenames[1] = r.drawable.tenm;         imagenames[2] = r.drawable.twentym;         imagenames[3] = r.drawable.thirtym;         imagenames[4] = r.drawable.fourtym;         imagenames[5] = r.drawable.fiftym;          // needs made here, once. never needs change.         mcirclepaint = new paint(paint.anti_alias_flag);         mcirclepaint.setcolor(0x10000000);         mcirclepaint.setstyle(style.fill_and_stroke);          // need load image once , keep drawing         // when dirtyed.         mbitmap = bitmapfactory.decoderesource(getresources(),                 imagenames[0]);          // point object changed every call topixels(),         // instance can recycled         mscreenpoints = new point();     }      public void setpointtodraw(geopoint point) {         pointtodraw = point;     }      public geopoint getpointtodraw() {         return pointtodraw;     }      @override     public boolean draw(canvas canvas, mapview mapview, boolean shadow,             long when) {         super.draw(canvas, mapview, shadow);         mscreenpoints = mapview.getprojection().topixels(pointtodraw,                 mscreenpoints);          int totalcircle = 5;         int radius = 40;         int centerimagesize = 13;          (int = 1; <= totalcircle; i++) {             canvas.drawcircle(mscreenpoints.x + 18, mscreenpoints.y + 36,                     * radius, mcirclepaint);             canvas.drawbitmap(bitmapfactory.decoderesource(getresources(),                     imagenames[i]), ((mscreenpoints.x) + (i * radius)),                     (mscreenpoints.y), null);         }          canvas.drawbitmap(mbitmap,                 (mscreenpoints.x - (centerimagesize / 2)),                 (mscreenpoints.y - (centerimagesize / 2)), null);         super.draw(canvas, mapview, shadow);          return true;     } } 

i need draw same circle have drawn in above code on google map v2. there way, can use above code googlemap object can draw circles on google map v2?

thanks help.

updated code:-

i need draw 5 circle-circle on google maps v2 taking current location center of circle. meaning each of 5 circles have same center different radii: first circle have radius of 10m, second circle radius of 20m, third circle radius of 30m, fourth circle radius of 40m, , fifth circle radius of 50m. using google maps v2.

and need show marker on center of circle well.

i trying draw circle on google map v2 draws 1 circle , not 5 circum-circle

circleoptions circleoptions = new circleoptions()                   .center(latlng)   //set center                   .radius(500)   //set radius in meters                   .fillcolor(color.transparent)  //default                   .strokecolor(0x10000000)                   .strokewidth(5);                    mycircle = googlemap.addcircle(circleoptions); 

i need draw circum-circle this-

enter image description here

can me this? having problem in making circle in google map v2. appreciated.

just add circle map using googlemap.addcircle(...)

see documentation

update:

i did said , had no problem doing want

enter image description here

here code, super simple super basic....

@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate){     view view = super.oncreateview(inflater, container, savedinstancestate);     googlemap map = getmap();      int radius = 500;      for(int i=0; i<5; i++){         map.addcircle(new circleoptions().center(new latlng(0,0)).radius(radius).fillcolor(0x30000000).strokewidth(3));         radius += 500;     }     return view; } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -