GroundOverlay | Android Developers - MIT

文章推薦指數: 80 %
投票人數:10人

Class Overview. A ground overlay is an image that is fixed to a map. A ground overlay has the following properties: Position: There are two ways to specify ... Quicknav Quicknav Design Develop Distribute GooglePlayDeveloperConsole AndroidDevelopersBlog AboutAndroid Android.com AndroidDevelopers AndroidOpenSourceProject English Español 日本語 한국어 Русский 中文(中国) 中文(台灣) close GetStarted Style Patterns BuildingBlocks Downloads Videos Training APIGuides Reference Tools GettheSDK GoogleServices GooglePlay Publishing Promoting AppQuality Spotlight OpenDistribution Results Loading... Training APIGuides Reference Tools GoogleServices totop APIlevel: AndroidAPIs com.google.android.gms com.google.android.gms.auth com.google.android.gms.common com.google.android.gms.common.data com.google.android.gms.common.images com.google.android.gms.maps com.google.android.gms.maps.model com.google.android.gms.panorama com.google.android.gms.plus com.google.android.gms.plus.model.moments com.google.android.gms.plus.model.people Interfaces TileProvider Classes BitmapDescriptor BitmapDescriptorFactory CameraPosition CameraPosition.Builder Circle CircleOptions GroundOverlay GroundOverlayOptions LatLng LatLngBounds LatLngBounds.Builder Marker MarkerOptions Polygon PolygonOptions Polyline PolylineOptions Tile TileOverlay TileOverlayOptions UrlTileProvider VisibleRegion Exceptions RuntimeRemoteException fullscreen UseTreeNavigationUsePanelNavigation Summary: Methods |InheritedMethods |[ExpandAll] public final class GroundOverlay extendsObject java.lang.Object    ↳ com.google.android.gms.maps.model.GroundOverlay ClassOverview Agroundoverlayisanimagethatisfixedtoamap.Agroundoverlayhasthefollowing properties: Position Therearetwowaystospecifythepositionofthegroundoverlay: Usinganlocation:Youmustprovideanimageofthegroundoverlay,aLatLngtowhich theanchorwillbefixedandthewidthoftheoverlay(inmeters).Theanchorisbydefault50% fromthetopoftheimageand50%fromtheleftoftheimage.Thiscanbechanged.Youcan optionallyprovidetheheightoftheoverlay(inmeters).Ifyoudonotprovidetheheightofthe overlay,itwillbeautomaticallycalculatedtopreservetheproportionsoftheimage. UsingaBounds:YoumustprovideaLatLngBoundswhichwillcontaintheimage. Youmustspecifythepositionofthegroundoverlaybeforeitisaddedtothemap,otherwisean IllegalArgumentExceptionwillbethrownwhenthegroundoverlayisaddedtothemap. Furthermore,youmustonlyspecifythepositionusingoneofthesemethodsinthe GroundOverlayOptionsobject;otherwiseanIllegalStateExceptionwillbethrown whenspecifyingusingasecondmethod. Image Theimage(asanBitmapDescriptor)tobeusedforthisoverlay.Theimagewillbe scaledtofitthepositionprovided.Youcannotchangetheimageusedinthegroundoverlayonce ithasbeenaddedtothemap.Youmustspecifyanimagebeforeaddingthegroundoverlaytothe map;ifnotanIllegalArgumentExceptionwillbethrownwhenitisaddedtothemap. Bearing Theamountthattheimageshouldberotatedinaclockwisedirection.Thecenterofthe rotationwillbetheimage'sanchor.Thisisoptionalandthedefaultbearingis0,i.e.,the imageisalignedsothatupisnorth. zIndex Theorderinwhichthisgroundoverlayisdrawnwithrespecttootheroverlays(including PolylinesandTileOverlays,butnotMarkers).Anoverlaywithalarger zIndexisdrawnoveroverlayswithsmallerzIndexes.TheorderofoverlayswiththesamezIndex valueisarbitrary.ThisisoptionalandthedefaultzIndexis0. Transparency Transparencyofthegroundoverlayintherange[0..1]where0meansthe overlayisopaqueand1meanstheoverlayisfullytransparent.Ifthespecifiedbitmap isalreadypartiallytransparent,thetransparencyofeachpixelwillbescaledaccordingly(e.g. ifapixelinthebitmaphasanalphavalueof200andyouspecifythetransparencyoftheground overlayas0.25,thenthepixelwillberenderedonthescreenwithanalphavalueof150).This isoptionalandthedefaulttransparencyis0(opaque). Visibility Indicatesifthegroundoverlayisvisibleorinvisible,i.e.whetheritisdrawnonthemap. Aninvisiblegroundoverlayisnotdrawn,butretainsallofitsotherproperties.Thisis optionalandthedefaultvisibilityistrue,i.e.,visible. MethodsthatmodifyaPolylinemustbecalledontheUIthread.Ifnot,an IllegalStateExceptionwillbethrownatruntime. Example GoogleMapmap=...;//getamap. BitmapDescriptorimage=...;//getanimage. LatLngBoundsbounds=...;//getabounds //Addsagroundoverlaywith50%transparency. GroundOverlaygroundOverlay=map.addGroundOverlay(newGroundOverlayOptions() .image(image) .positionFromBounds(bounds) .transparency(0.5)); Summary PublicMethods boolean equals(Objectother) float getBearing() Getsthebearingofthegroundoverlayindegreesclockwisefromnorth. LatLngBounds getBounds() Getstheboundsforthegroundoverlay. float getHeight() Getstheheightofthegroundoverlay. String getId() Getsthisgroundoverlay'sid. LatLng getPosition() Getsthelocationoftheanchoredpoint. float getTransparency() Getsthetransparencyofthisgroundoverlay. float getWidth() Getsthewidthofthegroundoverlay. float getZIndex() GetsthezIndexofthisgroundoverlay. int hashCode() boolean isVisible() Getsthevisibilityofthisgroundoverlay. void remove() Removesthisgroundoverlayfromthemap. void setBearing(floatbearing) Setsthebearingofthegroundoverlay(thedirectionthattheverticalaxisoftheground overlaypoints)indegreesclockwisefromnorth. void setDimensions(floatwidth) Setsthedimensionsofthegroundoverlay. void setDimensions(floatwidth,floatheight) Setsthedimensionsofthegroundoverlay. void setPosition(LatLnglatLng) Setsthepositionofthegroundoverlaybychangingthelocationoftheanchoredpoint. void setPositionFromBounds(LatLngBoundsbounds) SetsthepositionofthegroundoverlaybyfittingittothegivenLatLngBounds. void setTransparency(floattransparency) Setsthetransparencyofthisgroundoverlay. void setVisible(booleanvisible) Setsthevisibilityofthisgroundoverlay. void setZIndex(floatzIndex) SetsthezIndexofthisgroundoverlay. [Expand] InheritedMethods Fromclass java.lang.Object Object clone() boolean equals(Objectarg0) void finalize() final Class> getClass() int hashCode() final void notify() final void notifyAll() String toString() final void wait() final void wait(longarg0,intarg1) final void wait(longarg0) PublicMethods public boolean equals (Objectother) public float getBearing () Getsthebearingofthegroundoverlayindegreesclockwisefromnorth. Returns thebearingofthegroundoverlay. public LatLngBounds getBounds () Getstheboundsforthegroundoverlay.Thisignorestherotationofthegroundoverlay. Returns aLatLngBoundsthatcontainsthegroundoverlay,ignoringrotation. public float getHeight () Getstheheightofthegroundoverlay. Returns theheightofthegroundoverlayinmeters. public String getId () Getsthisgroundoverlay'sid. WhenamapisrestoredfromaBundle,groundoverlaysthatwereonthat maparealsorestored.However,thosegroundoverlayswillthenberepresentedbydifferent GroundOverlayobjects.Agroundoverlay'sidcanbeusedtoretrievethenew instanceofaGroundOverlayobjectaftersuchrestoration. Returns thisgroundoverlay'sid. public LatLng getPosition () Getsthelocationoftheanchoredpoint. Returns thepositiononthemap(aLatLng). public float getTransparency () Getsthetransparencyofthisgroundoverlay. Returns thetransparencyofthisgroundoverlay. public float getWidth () Getsthewidthofthegroundoverlay. Returns thewidthofthegroundoverlayinmeters. public float getZIndex () GetsthezIndexofthisgroundoverlay. Returns thezIndexofthegroundoverlay. public int hashCode () public boolean isVisible () Getsthevisibilityofthisgroundoverlay.Notethatthisdoesnotreturnwhethertheground overlayisactuallyonscreen,butwhetheritwillbedrawnifitiscontainedinthe camera'sviewport. Returns thisgroundoverlay'svisibility. public void remove () Removesthisgroundoverlayfromthemap.Afteragroundoverlayhasbeenremoved,the behaviorofallitsmethodsisundefined. public void setBearing (floatbearing) Setsthebearingofthegroundoverlay(thedirectionthattheverticalaxisoftheground overlaypoints)indegreesclockwisefromnorth.Therotationisperformedabouttheanchor point. Parameters bearing bearingindegreesclockwisefromnorth public void setDimensions (floatwidth) Setsthedimensionsofthegroundoverlay.Theheightofthegroundoverlaywillbe calculatedtopreservetheproportionsinheritedfromthebitmap. Parameters width widthinmeters public void setDimensions (floatwidth,floatheight) Setsthedimensionsofthegroundoverlay.Theimagewillbestretched(andhencemaynot retainitsproportions)tofitthesedimensions. Parameters width widthinmeters height heightinmeters public void setPosition (LatLnglatLng) Setsthepositionofthegroundoverlaybychangingthelocationoftheanchoredpoint. Preservesallotherpropertiesoftheimage. Parameters latLng aLatLngthatisthenewlocationtoplacetheanchorpoint. public void setPositionFromBounds (LatLngBoundsbounds) SetsthepositionofthegroundoverlaybyfittingittothegivenLatLngBounds.This methodwillignoretherotation(bearing)ofthegroundoverlaywhenpositioningit,butthe bearingwillstillbeusedwhendrawingit. Parameters bounds aLatLngBoundsinwhichtoplacethegroundoverlay public void setTransparency (floattransparency) Setsthetransparencyofthisgroundoverlay.Seethedocumentationatthetopofthisclass formoreinformation. Parameters transparency afloatintherange[0..1]where0meansthattheground overlayisopaqueand1meansthatthegroundoverlayistransparent public void setVisible (booleanvisible) Setsthevisibilityofthisgroundoverlay.Whennotvisible,agroundoverlayisnotdrawn, butitkeepsallofitsotherproperties. Parameters visible iftrue,thenthegroundoverlayisvisible;iffalse,itis not public void setZIndex (floatzIndex) SetsthezIndexofthisgroundoverlay.Seethedocumentationatthetopofthisclassfor moreinformation. Parameters zIndex thezIndexofthisgroundoverlay Exceptasnoted,thiscontentislicensedunderApache2.0. Fordetailsandrestrictions,seethe ContentLicense. Android r—12Mar20133:07 AboutAndroid  |  Legal  |  Support



請為這篇文章評分?