How to resize polygon drawn on Google map in Android? -
after searching lot found solution draw polygon free hand on google map in android.
now want resize polygon dragging on map, don't know how that.
private googlemap mmap; polygonoptions rectoptions; polygon shape; private bool is_map_moveable = false; // detect map movable // on create framelayout fram_map = (framelayout)findviewbyid(resource.id.fram_map); button btn_draw_state = (button)findviewbyid(resource.id.btn_draw_state); if (btn_draw_state != null) { btn_draw_state.click += (sender, e) => { if (!is_map_moveable) { is_map_moveable = true; fram_map.setontouchlistener(this); } else if (is_map_moveable) { is_map_moveable = false; } } ; } list<latlng> val = new list<latlng>(); public bool ontouch(view v, motionevent e) { float x = e.getx(); float y = e.gety(); int x_co = (int)math.round(x); int y_co = (int)math.round(y); projection p = mmap.projection; point x_y_points = new point(x_co, y_co); latlng latlng = mmap.projection.fromscreenlocation(x_y_points); var latitude = latlng.latitude; var longitude = latlng.longitude; int eventaction = (int)e.action; switch (e.action) { case motioneventactions.down: // finger touches screen val.add(new latlng(latitude, longitude)); break; case motioneventactions.move: // finger moves on screen val.add(new latlng(latitude, longitude)); break; case motioneventactions.up: // finger leaves screen drawmap(); break; } if (is_map_moveable == true) { return true; } else { return false; } } private void drawmap() { rectoptions = new polygonoptions(); foreach(var item in val) { rectoptions.add(item); } rectoptions.invokefillcolor(int.parse("33ff0000", system.globalization.numberstyles.hexnumber)); rectoptions.invokestrokecolor(int.parse("ff33a02c", system.globalization.numberstyles.hexnumber)); rectoptions.invokestrokewidth(3); rectoptions.clickable(true); shape = mmap.addpolygon(rectoptions); }
Comments
Post a Comment