android - How to add image at specific location in maps? -
in project want add image @ particular location in map.for used following code.
public class sample extends activity { @targetapi(build.version_codes.honeycomb) @suppresslint("newapi") @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.sample); // handle map fragment googlemap map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); latlng sydney = new latlng(33.6671688,-117.9053506); map.setmylocationenabled(true); map.movecamera(cameraupdatefactory.newlatlngzoom(sydney, 15)); //add overlay bitmapdescriptor image = bitmapdescriptorfactory.fromresource(r.drawable.categorymap); groundoverlayoptions groundoverlay = new groundoverlayoptions() .image(image) .position(sydney, 1000f) .transparency(0.1f); map.addgroundoverlay(groundoverlay); } }
by using code map displayed following screenshot.
but requirement add image @ particular location following screenshot.for have latitude , longitude values show map location.in location want add image following screenshot.
so question is,how move image left right above screenshot.i tried alot doing didnt solve issue.so please suggest me how solve problem.thanks inadvance all...
try exact positions of corners of building , uses method
public groundoverlayoptions positionfrombounds (latlngbounds bounds)
then should scale mapzoom
another way use anchor
edit:
groundoverlayoptions groundoverlay = new groundoverlayoptions() .image(image) .position(sydney, 1000f) .transparency(0.1f) .anchor(0.5, 0.5);
this instead make lat/lon in center of image.
Comments
Post a Comment