Circle | Maps SDK for Android - Google Developers

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

GoogleMap map; // ... get a map. // Add a circle in Sydney Circle circle = map.addCircle(new CircleOptions() .center(new LatLng(-33.87365, ... Google MapsPlatform Overview Products Pricing Documentation GetStarted GetStartedwithGoogleMapsPlatform APIPicker Billing&Pricing Reporting&Monitoring MapIDs FAQ SupportandResources IncidentManagement Maps MapsJavaScriptAPI MapsSDKforAndroid MapsSDKforiOS MapsStaticAPI StreetViewStaticAPI MapsEmbedAPI MapsURLs MapsElevationAPI Routes DirectionsAPI DistanceMatrixAPI RoadsAPI Solutions IndustrySolutions GamingServices TransportationandLogistics Places PlacesAPI PlacesSDKforAndroid PlacesSDKforiOS PlacesLibrary,MapsJavaScriptAPI GeocodingAPI GeolocationAPI TimeZoneAPI AdditionalResources APISecurityBestPractices MapCoverageDetails OptimizationGuide MobileOSandsoftwaresupport Deprecations AssetTrackingPlan RootCAMigrationFAQ URLEncoding WordPressUsers Blog Community StackOverflow GitHub YouTube Discord Twitter IssueTracker Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어 Signin Android MapsSDKforAndroid GetStarted Contactsales Guides Reference Samples Support Google MapsPlatform Overview Products Pricing Documentation More Guides Reference Samples Support Blog Community More Reference com.google.android.gms.maps com.google.android.gms.maps.model Beta(Deprecated) com.google.android.libraries.maps OverviewCameraUpdateCameraUpdateFactory GoogleMap OverviewCancelableCallbackInfoWindowAdapterOnCameraChangeListenerOnCameraIdleListenerOnCameraMoveCanceledListenerOnCameraMoveListenerOnCameraMoveStartedListenerOnCircleClickListenerOnGroundOverlayClickListenerOnIndoorStateChangeListenerOnInfoWindowClickListenerOnInfoWindowCloseListenerOnInfoWindowLongClickListenerOnMapClickListenerOnMapLoadedCallbackOnMapLongClickListenerOnMarkerClickListenerOnMarkerDragListenerOnMyLocationButtonClickListenerOnMyLocationChangeListenerOnMyLocationClickListenerOnPoiClickListenerOnPolygonClickListenerOnPolylineClickListenerSnapshotReadyCallbackGoogleMapOptions LocationSource OverviewOnLocationChangedListenerMapFragmentMapViewMapsInitializerOnMapReadyCallbackOnStreetViewPanoramaReadyCallbackProjection StreetViewPanorama OverviewOnStreetViewPanoramaCameraChangeListenerOnStreetViewPanoramaChangeListenerOnStreetViewPanoramaClickListenerOnStreetViewPanoramaLongClickListenerStreetViewPanoramaFragmentStreetViewPanoramaOptionsStreetViewPanoramaViewSupportMapFragmentSupportStreetViewPanoramaFragmentUiSettings com.google.android.libraries.maps.model OverviewBitmapDescriptorBitmapDescriptorFactoryButtCap CameraPosition OverviewBuilderCapCircleCircleOptionsCustomCapDashDotGapGroundOverlayGroundOverlayOptionsIndoorBuildingIndoorLevelJointTypeLatLng LatLngBounds OverviewBuilderMapStyleOptions Marker OverviewCollisionBehaviorMarkerOptionsPatternItemPointOfInterestPolygonPolygonOptionsPolylinePolylineOptionsRoundCapRuntimeRemoteException SpriteStyle OverviewBuilderSquareCapStampStyle StreetViewPanoramaCamera OverviewBuilderStreetViewPanoramaLinkStreetViewPanoramaLocation StreetViewPanoramaOrientation OverviewBuilderStreetViewSource StrokeStyle OverviewBuilderStyleSpan TextureStyle OverviewBuilderTileTileOverlayTileOverlayOptionsTileProviderUrlTileProviderVisibleRegion GetStarted GetStartedwithGoogleMapsPlatform APIPicker Billing&Pricing Reporting&Monitoring MapIDs FAQ SupportandResources IncidentManagement Maps MapsJavaScriptAPI MapsSDKforAndroid MapsSDKforiOS MapsStaticAPI StreetViewStaticAPI MapsEmbedAPI MapsURLs MapsElevationAPI Routes DirectionsAPI DistanceMatrixAPI RoadsAPI Solutions IndustrySolutions GamingServices TransportationandLogistics Places PlacesAPI PlacesSDKforAndroid PlacesSDKforiOS PlacesLibrary,MapsJavaScriptAPI GeocodingAPI GeolocationAPI TimeZoneAPI AdditionalResources APISecurityBestPractices MapCoverageDetails OptimizationGuide MobileOSandsoftwaresupport Deprecations AssetTrackingPlan RootCAMigrationFAQ URLEncoding WordPressUsers StackOverflow GitHub YouTube Discord Twitter IssueTracker Home Products GoogleMapsPlatform Documentation Android MapsSDKforAndroid Reference Sendfeedback Circle publicfinalclass Circle extendsObject Acircleontheearth'ssurface(sphericalcap). Acirclehasthefollowingproperties. Center ThecenteroftheCircleisspecifiedasaLatLng. Radius Theradiusofthecircle,specifiedinmeters.Itshouldbezeroorgreater. StrokeWidth Thewidthofthecircle'soutlineinscreenpixels.Thewidthisconstantandindependent ofthecamera'szoomlevel.Thedefaultvalueis10. StrokeColor ThecolorofthecircleoutlineinARGBformat,thesameformatusedbyColor.Thedefaultvalueisblack(0xff000000). Strokepattern Solid(default,representedbynull)orasequenceofPatternItemobjects toberepeatedalongthecircle'soutline.AvailablePatternItemtypes:Gap (definedbygaplengthinpixels),Dash(definedbystrokewidthanddashlengthin pixels)andDot(circular,centeredonthecircle'soutline,diameterdefinedby strokewidthinpixels). FillColor ThecolorofthecirclefillinARGBformat,thesameformatusedbyColor.Thedefaultvalueistransparent(0x00000000). Z-Index Theorderinwhichthistileoverlayisdrawnwithrespecttootheroverlays(including GroundOverlays,TileOverlays,Polylines,andPolygonsbut notMarkers).Anoverlaywithalargerz-indexisdrawnoveroverlayswithsmaller z-indices.Theorderofoverlayswiththesamez-indexisarbitrary.ThedefaultzIndexis 0. Visibility Indicatesifthecircleisvisibleorinvisible,i.e.,whetheritisdrawnonthemap.An invisiblecircleisnotdrawn,butretainsallofitsotherproperties.Thedefaultis true,i.e.,visible. Tag AnObjectassociatedwiththecircle.Forexample,theObjectcancontain dataaboutwhatthecirclerepresents.ThisiseasierthanstoringaseparateMap.Asanotherexample,youcanassociateaStringID correspondingtotheIDfromadataset.GoogleMapsSDKforAndroidneitherreadsnor writesthisproperty. MethodsinthisclassmustbecalledontheAndroidUIthread.Ifnot,anIllegalStateExceptionwillbethrownatruntime. Example GoogleMapmap; //...getamap. //AddacircleinSydney Circlecircle=map.addCircle(newCircleOptions() .center(newLatLng(-33.87365,151.20689)) .radius(10000) .strokeColor(Color.RED) .fillColor(Color.BLUE)); Notethatthecurrentmaprendererisunabletodrawthecirclefillifthe circleencompasseseithertheNorthorSouthpole.However,theoutlinewillstillbedrawn correctly. DeveloperGuide Formoreinformation,readtheShapesdeveloper guide. PublicMethodSummary LatLng getCenter() ReturnsthecenterasaLatLng. int getFillColor() ReturnsthefillcolorofthisCircle. String getId() Getsthiscircle'sid. double getRadius() Returnsthecircle'sradius,inmeters. int getStrokeColor() Returnsthestrokecolor. List getStrokePattern() Returnsthestrokepatternofthiscircle'soutline. float getStrokeWidth() Returnsthestrokewidth. Object getTag() Getsthetagforthecircle. float getZIndex() ReturnsthezIndex. boolean isClickable() Getstheclickabilityofthecircle. boolean isVisible() Checkswhetherthecircleisvisible. void remove() Removesthiscirclefromthemap. void setCenter(LatLngcenter) SetsthecenterusingaLatLng. void setClickable(booleanclickable) Setstheclickabilityofthecircle. void setFillColor(intcolor) Setsthefillcolor. void setRadius(doubleradius) Setstheradiusinmeters. void setStrokeColor(intcolor) Setsthestrokecolor. void setStrokePattern(Listpattern) Setsthestrokepatternofthecircle'soutline. void setStrokeWidth(floatwidth) Setsthestrokewidth. void setTag(Objecttag) Setsthetagforthecircle. void setVisible(booleanvisible) Setsthevisibilityofthecircle. void setZIndex(floatzIndex) SetsthezIndex. InheritedMethodSummary Fromclass java.lang.Object boolean equals(Objectarg0) final Class> getClass() int hashCode() final void notify() final void notifyAll() String toString() final void wait(longarg0,intarg1) final void wait(longarg0) final void wait() PublicMethods public LatLng getCenter () ReturnsthecenterasaLatLng. Returns ThegeographiccenterasaLatLng. public int getFillColor () ReturnsthefillcolorofthisCircle. Returns ThefillcolorofthecircleinARGBformat. public String getId () Getsthiscircle'sid.TheidwillbeuniqueamongstallCirclesonamap. public double getRadius () Returnsthecircle'sradius,inmeters. Returns Theradiusinmeters. public int getStrokeColor () Returnsthestrokecolor. Returns ThecolorofthecircleinARGBformat. public List getStrokePattern () Returnsthestrokepatternofthiscircle'soutline. Returns thestrokepattern. public float getStrokeWidth () Returnsthestrokewidth. Returns Thewidthinscreenpixels. public Object getTag () Getsthetagforthecircle. Returns thetagifatagwassetwithsetTag;nullifnotaghasbeenset. public float getZIndex () ReturnsthezIndex. Returns ThezIndexofthiscircle. public boolean isClickable () Getstheclickabilityofthecircle.Ifthecircleisclickable,yourappwillreceive notificationstotheGoogleMap.OnCircleClickListenerwhentheuserclicksthecircle. TheeventlistenerisregisteredthroughsetOnCircleClickListener(GoogleMap.OnCircleClickListener). Returns trueifthecircleisclickable;falseifitisnotclickable. public boolean isVisible () Checkswhetherthecircleisvisible. Returns trueifthecircleisvisible;falseifitisinvisible. public void remove () Removesthiscirclefromthemap.Afteracirclehasbeenremoved,thebehaviorofallits methodsisundefined. public void setCenter (LatLngcenter) SetsthecenterusingaLatLng. Thecentermustnotbenull,asthereisnodefaultvalue. Parameters center Thegeographiccenterofthecircle,specifiedasaLatLng. Throws NullPointerException ifcenterisnull public void setClickable (booleanclickable) Setstheclickabilityofthecircle.Ifthecircleisclickable,yourappwillreceive notificationstotheGoogleMap.OnCircleClickListenerwhentheuserclicksthecircle. TheeventlistenerisregisteredthroughsetOnCircleClickListener(GoogleMap.OnCircleClickListener). Parameters clickable Newclickabilitysettingforthecircle. public void setFillColor (intcolor) Setsthefillcolor. Thefillcoloristhecolorinsidethecircle,intheintegerformatspecifiedbyColor.IfTRANSPARENTisusedthennofillisdrawn. Parameters color ThecolorintheColorformat. public void setRadius (doubleradius) Setstheradiusinmeters. Theradiusmustbezeroorgreater. Parameters radius Theradius,inmeters. Throws IllegalArgumentException ifradiusisnegative public void setStrokeColor (intcolor) Setsthestrokecolor. Thestrokecoloristhecolorofthiscircle'soutline,intheintegerformatspecifiedby Color.IfTRANSPARENTisusedthennooutlineisdrawn. Parameters color ThestrokecolorintheColorformat. public void setStrokePattern (Listpattern) Setsthestrokepatternofthecircle'soutline.Thedefaultstrokepatternissolid, representedbynull. Parameters pattern thestrokepattern. public void setStrokeWidth (floatwidth) Setsthestrokewidth. Thestrokewidthisthewidth(inscreenpixels)ofthecircle'soutline.Itmustbezeroor greater.Ifitiszerothennooutlineisdrawn.Thedefaultvalueis10. Parameters width Thestrokewidth,inscreenpixels. Throws IllegalArgumentException ifwidthisnegative public void setTag (Objecttag) Setsthetagforthecircle. YoucanusethispropertytoassociateanarbitraryObjectwiththiscircle.For example,theObjectcancontaindataaboutwhatthecirclerepresents.Thisiseasier thanstoringaseparateMap.Asanotherexample,youcanassociatea StringIDcorrespondingtotheIDfromadataset.GoogleMapsSDKforAndroidneither readsnorwritesthisproperty.ItisyourresponsibilitytocallsetTag(null)toclear thetagwhenyounolongerneedit,topreventmemoryleaksinyourapp. Parameters tag ifnull,thetagiscleared. public void setVisible (booleanvisible) Setsthevisibilityofthecircle. Ifthiscircleisnotvisiblethenitwillnotbedrawn.Allotherstateispreserved. Circlesarevisiblebydefault. Parameters visible truetomakethiscirclevisible;falsetomakeitinvisible. public void setZIndex (floatzIndex) SetsthezIndex. Overlays(suchascircles)withhigherzIndicesaredrawnabovethosewithlowerindices. Parameters zIndex ThezIndexvalue. Sendfeedback Exceptasotherwisenoted,thecontentofthispageislicensedundertheCreativeCommonsAttribution4.0License,andcodesamplesarelicensedundertheApache2.0License.Fordetails,seetheGoogleDevelopersSitePolicies.JavaisaregisteredtrademarkofOracleand/oritsaffiliates. Lastupdated2022-06-22UTC. [{ "type":"thumb-down", "id":"missingTheInformationINeed", "label":"MissingtheinformationIneed" },{ "type":"thumb-down", "id":"tooComplicatedTooManySteps", "label":"Toocomplicated/toomanysteps" },{ "type":"thumb-down", "id":"outOfDate", "label":"Outofdate" },{ "type":"thumb-down", "id":"samplesCodeIssue", "label":"Samples/codeissue" },{ "type":"thumb-down", "id":"otherDown", "label":"Other" }] [{ "type":"thumb-up", "id":"easyToUnderstand", "label":"Easytounderstand" },{ "type":"thumb-up", "id":"solvedMyProblem", "label":"Solvedmyproblem" },{ "type":"thumb-up", "id":"otherUp", "label":"Other" }] Needtotellusmore? StackOverflow Askaquestionunderthegoogle-mapstag. GitHub Forkoursamplesandtrythemyourself. Discord ChatwithfellowdevelopersaboutGoogleMapsPlatform. IssueTracker Somethingwrong?Sendusabugreport! LearnMore FAQ APIPicker PlacesSDKforAndroid Platforms Android iOS Web WebServices ProductInfo PricingandPlans ContactSales Support TermsofService Android Chrome Firebase GoogleCloudPlatform Allproducts Terms Privacy SignupfortheGoogleDevelopersnewsletter Subscribe Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어



請為這篇文章評分?