android - OSMDroid offset polygon -
i draw polygon on map using code similar :
geopoint pt1=new geopoint(13002798,77580000); geopoint pt2= new geopoint(pt1.getlatitudee6()+diff, pt1.getlongitudee6()); geopoint pt3= new geopoint(pt1.getlatitudee6()+diff, pt1.getlongitudee6()+diff); geopoint pt4= new geopoint(pt1.getlatitudee6(), pt1.getlongitudee6()+diff); geopoint pt5= new geopoint(pt1); pathoverlay myoverlay= new pathoverlay(color.red, this); myoverlay.getpaint().setstyle(paint.style.fill); myoverlay.addpoint(pt1); myoverlay.addpoint(pt2); myoverlay.addpoint(pt3); myoverlay.addpoint(pt4); myoverlay.addpoint(pt5); map.getoverlays().add(myoverlay);
now want offset overlay polygon 10px up, independent of zoom or other parameters. how can that? need draw line above poi marker arrows.
something that:
projection pj = mapview.getprojection(); point pix = pj.topixels(p); pix.y -= 10; //10 pixels geopoint p2 = pj.frompixels(pix2.x, pix2.y); double offset = p2.getlatitude() - p.getlatitude();
then can offset latitude of points adding offset.
however, solution little bit strange. instead, display polygon "under" poi markers. osmdroid displays overlays following order: first @ bottom, latest on top.
latest point: never use pathoverlay filled polygons, weird behaviours in cases (when part of polygon inside view, part outside). can use osmbonuspack polygon instead.
Comments
Post a Comment