Google Map Overlays - HTML Tutorial
文章推薦指數: 80 %
The map itself is displayed using a tile overlay. If you own a series of tiles, ... Examples. var marker=new google.maps.Marker({ position:myCenter, }); w3big.com Latestwebdevelopmenttutorials ☰ HTML CSS JAVASCRIPT SQL PHP BOOTSTRAP JQUERY ANGULAR XML PYTHON 简体中文繁體中文日本语한국어ไทยالعربيةPortuguêsIndonesiaEspañolItalianoDeutschFrançaisPусскийpolskiEnglish × × × × GoogleMapsAPITutorial GoogleAPITutorial GooglemapAPI GoogleMapbasis GoogleMapOverlay GoogleMapevents GoogleAsetofmapcontrols GoogleThemaptype GoogleMapReferenceManual MapconstructorAPIMap() GoogleMapOverlays Previous:GoogleMapsbaseNext:GoogleMapsEventAddingamarkerinGoogleMapsGoogleMaps-OverlaysOverlaysareobjectsboundtothelatitude/longitudecoordinatesonthemap,dragorzoomthemapwillmovewithyou.GoogleMapsAPIarethefollowingoverlays:Pointusingmarkersonthemaptoshowtheoftendisplayacustomicon.MarkersareobjectsGMarkertype,andcanbeusedtocustomizethetypesofobjectsGIconicon.Linesonthemapusingpolylines(representingacollectionofpoints)tobedisplayed.GPolylinelineoftypeobject.Areasonthemapisdisplayedaspolygons(iftheareaisanarbitraryshape)orbottomoverlay(ifitisarectangulararea).Polygonsimilartoaclosedpolyline,itcanbeanyshape.Groundoverlaysarecommonlyusedtomaptheareawithtilesdirectlyorindirectlyassociated.Themapitselfisdisplayedusingatileoverlay.Ifyouownaseriesoftiles,youcanuseGTileLayerOverlayclasstochangetheexistingtilesonthemap,youcanevenuseGMapTypetocreateyourownmaptypes.Informationwindowisalsoaspecialkindofoverlay.Note,however,theinformationwindowwillbeautomaticallyaddedtothemap,andthemapcanonlyaddonetypeGInfoWindowobject.GoogleMaps-AddtagMapidentifiespointsontherecord.Bydefault,theyuseG_DEFAULT_ICON(Youcanalsospecifyacustomicon).GMarkerconstructorGLatLngandGMarkerOptions(optional)objectasaparameter.Tagsdesignedtobeinteractive.Forexample,bydefault,theyreceive"click"events,oftenusedtoopentheinfowindowintheeventlisteners.BysetMap()methodtoaddmarkersonthemap:Examples varmarker=newgoogle.maps.Marker({ position:myCenter, }); marker.setMap(map);tryit"GoogleMaps-draggablemarkerThefollowingexampledescribeshowtousetheanimationpropertytodragthemarker:Examples marker=newgoogle.maps.Marker({ position:myCenter, animation:google.maps.Animation.BOUNCE }); marker.setMap(map);tryit"GoogleMaps-iconTagcanbedefinedfromthenewiconisdisplayedinplaceofthedefaulticon:Examples varmarker=newgoogle.maps.Marker({ position:myCenter, icon:'pinkball.png' }); marker.setMap(map);tryit"GoogleMaps-polylineGPolylineobjectcancreatealinearoverlayonthemap.GPolylineincludeaseriesofpointsandcreatesaseriesoforderlylinesconnectingthesepoints.Polylinesupportsthefollowingattributes:path-specifymorethanonelineoflatitude/longitudecoordinatesstrokeColor-specifiesthehexadecimalcolorvalueoftheline(format:"#FFFFFF")strokeOpacity-Transparencydesignatedline(thevalue0.0to1.0)strokeWeight-Definesthewidthoftheline,inpixels.editable-whethertheusercaneditthedefinitionofastraightline(true/false)Examples varmyTrip=[stavanger,amsterdam,london]; varflightPath=newgoogle.maps.Polyline({ path:myTrip, strokeColor:"#0000FF", strokeOpacity:0.8, strokeWeight:2 });tryit"GoogleMaps-PolygonGPolygonobjectsaresimilarGPolylineobjectsbecausetheyincludeaseriesoforderedpoints.However,thepolygonsaretwoendpoints,butthedesignoftheclosedloopareaisdefinedformation.Andtheline,youcancustomizethecolorandtransparencyofthepolygonedges(lines)color,thicknessandtransparency,aswellastheclosureofthefilledarea.ColorsshouldbeinhexadecimalnumericHTMLstyle.Polygonsupportsthefollowingattributes:path-specifymultiplelinearlatitudecoordinates(firstandlastcoordinatesareequal)strokeColor-specifiesthehexadecimalcolorvalueoftheline(format:"#FFFFFF")strokeOpacity-Transparencydesignatedline(thevalue0.0to1.0)strokeWeight-Definesthewidthoftheline,inpixels.fillColor-closedareadesignatedhexadecimalcolorvalues(format:"#FFFFFF")fillOpacity-Transparencyspecifythefillcolor(whichis0.0to1.0)editable-whethertheusercaneditthedefinitionofastraightline(true/false)Examples varmyTrip=[stavanger,amsterdam,london,stavanger]; varflightPath=newgoogle.maps.Polygon({ path:myTrip, strokeColor:"#0000FF", strokeOpacity:0.8, strokeWeight:2, fillColor:"#0000FF", fillOpacity:0.4 });tryit"GoogleMaps-RoundRoundsupportsthefollowingattributes:center-thecenterpointofthecirclespecifiedparametersgoogle.maps.LatLngradius-specifiestheradiusofthecircle,inmetersstrokeColor-Specifiesthearchexadecimalcolorvalues(format:"#FFFFFF")strokeOpacity-Transparencydesignatedarc(thevalue0.0to1.0)strokeWeight-Definesthewidthoftheline,inpixels.fillColor-specifiesthehexadecimalcolorvalueofthecirclefillvalue(format:"#FFFFFF")fillOpacity-Transparencyspecifythefillcolor(whichis0.0to1.0)Defineswhethertheusercaneditastraightline(true/false)Examples varmyCity=newgoogle.maps.Circle({ center:amsterdam, radius:20000, strokeColor:"#0000FF", strokeOpacity:0.8, strokeWeight:2, fillColor:"#0000FF", fillOpacity:0.4 });tryit"GoogleMaps-InformationwindowOnatagtodisplayatextmessagewindow:Examples varinfowindow=newgoogle.maps.InfoWindow({ content:"HelloWorld!" }); infowindow.open(map,marker);tryit"GoogleMaps-overlayReferenceManualGoogleMapsAPIReferenceManual.Previous:GoogleMapsbaseNext:GoogleMapsEvent
延伸文章資訊
- 1Google Maps Overlays - W3Schools
Google Maps - Overlays. Overlays are objects on the map that are bound to latitude/longitude coor...
- 2Creating Image Overlays in Google Earth Desktop
Add an Image Overlay
- 3Custom Overlays | Maps JavaScript API - Google Developers
Overlays are objects on the map that are tied to latitude/longitude coordinates, so they move whe...
- 4How to Overlay Polygon Shapes Onto Google Maps - Resources
In this tutorial, you'll learn how to overlay polygon shapes onto Google Maps and embed it into a...
- 5Moving a custom overlay in Google Maps javascript API v3
I found no problem in doing it using Google Maps Markers, but I need a more customized marker so ...