Google Maps Overlays - W3Schools
文章推薦指數: 80 %
Example. var marker = new google.maps.Marker({ position:myCenter, animation:google.maps.Animation.BOUNCE }); marker.setMap(map); ... Tutorials References Exercises Videos Menu Login GetCertified WebsiteNEW ProNEW HTML CSS JAVASCRIPT SQL PYTHON PHP BOOTSTRAP HOWTO W3.CSS JAVA JQUERY C C++ C# R React Darkmode Darkcode × Tutorials HTMLandCSS LearnHTML LearnCSS LearnRWD LearnBootstrap LearnW3.CSS LearnColors LearnIcons LearnGraphics LearnSVG LearnCanvas LearnHowTo LearnSass DataAnalytics LearnAI LearnMachineLearning LearnDataScience LearnNumPy LearnPandas LearnSciPy LearnMatplotlib LearnStatistics LearnExcel XMLTutorials LearnXML LearnXMLAJAX LearnXMLDOM LearnXMLDTD LearnXMLSchema LearnXSLT LearnXPath LearnXQuery JavaScript LearnJavaScript LearnjQuery LearnReact LearnAngularJS LearnJSON LearnAJAX LearnAppML LearnW3.JS Programming LearnPython LearnJava LearnC LearnC++ LearnC# LearnR LearnKotlin LearnGo LearnDjango LearnTypeScript ServerSide LearnSQL LearnMySQL LearnPHP LearnASP LearnNode.js LearnRaspberryPi LearnGit LearnAWSCloud WebBuilding CreateaWebsiteNEW WhereToStart WebTemplates WebStatistics WebCertificates WebDevelopment CodeEditor TestYourTypingSpeed PlayaCodeGame CyberSecurity Accessibility DataAnalytics LearnAI LearnMachineLearning LearnDataScience LearnNumPy LearnPandas LearnSciPy LearnMatplotlib LearnStatistics LearnExcel LearnGoogleSheets XMLTutorials LearnXML LearnXMLAJAX LearnXMLDOM LearnXMLDTD LearnXMLSchema LearnXSLT LearnXPath LearnXQuery × References HTML HTMLTagReference HTMLBrowserSupport HTMLEventReference HTMLColorReference HTMLAttributeReference HTMLCanvasReference HTMLSVGReference GoogleMapsReference CSS CSSReference CSSBrowserSupport CSSSelectorReference Bootstrap3Reference Bootstrap4Reference W3.CSSReference IconReference SassReference JavaScript JavaScriptReference HTMLDOMReference jQueryReference AngularJSReference AppMLReference W3.JSReference Programming PythonReference JavaReference ServerSide SQLReference MySQLReference PHPReference ASPReference XML XMLDOMReference XMLHttpReference XSLTReference XMLSchemaReference CharacterSets HTMLCharacterSets HTMLASCII HTMLANSI HTMLWindows-1252 HTMLISO-8859-1 HTMLSymbols HTMLUTF-8 × ExercisesandQuizzes Exercises HTMLExercises CSSExercises JavaScriptExercises SQLExercises MySQLExercises PHPExercises PythonExercises NumPyExercises PandasExercises SciPyExercises jQueryExercises JavaExercises C++Exercises C#Exercises RExercises KotlinExercises GoExercises BootstrapExercises Bootstrap4Exercises Bootstrap5Exercises GitExercises Quizzes HTMLQuiz CSSQuiz JavaScriptQuiz SQLQuiz MySQLQuiz PHPQuiz PythonQuiz NumPyQuiz PandasQuiz SciPyQuiz jQueryQuiz JavaQuiz C++Quiz C#Quiz RQuiz KotlinQuiz XMLQuiz BootstrapQuiz Bootstrap4Quiz Bootstrap5Quiz CyberSecurityQuiz AccessibilityQuiz Courses HTMLCourse CSSCourse JavaScriptCourse FrontEndCourse SQLCourse PHPCourse PythonCourse NumPyCourse PandasCourse DataAnalyticsCourse jQueryCourse JavaCourse C++Course C#Course RCourse XMLCourse CyberSecurityCourse AccessibilityCourse Certificates HTMLCertificate CSSCertificate JavaScriptCertificate FrontEndCertificate SQLCertificate PHPCertificate PythonCertificate DataScienceCertificate Bootstrap3Certificate Bootstrap4Certificate jQueryCertificate JavaCertificate C++Certificate ReactCertificate XMLCertificate × Tutorials References Exercises PaidCourses Spaces Videos Shop Pro HTMLGraphics GraphicsHOME GoogleMaps MapsIntro MapsBasic MapsOverlays MapsEvents MapsControls MapsTypes MapsReference SVGTutorial SVGIntro SVGinHTML SVGRectangle SVGCircle SVGEllipse SVGLine SVGPolygon SVGPolyline SVGPath SVGText SVGStroking SVGFiltersIntro SVGBlurEffects SVGDropShadows SVGLinear SVGRadial SVGExamples SVGReference CanvasTutorial CanvasIntro CanvasDrawing CanvasCoordinates CanvasGradients CanvasText CanvasImages CanvasReference CanvasClock ClockIntro ClockFace ClockNumbers ClockHands ClockStart HTMLGame GameIntro GameCanvas GameComponents GameControllers GameObstacles GameScore GameImages GameSound GameGravity GameBouncing GameRotation GameMovement GoogleMapsOverlays ❮Previous Next❯ GoogleMaps-Overlays Overlaysareobjectsonthemapthatareboundtolatitude/longitude coordinates. GoogleMapshasseveraltypesofoverlays: Marker-Singlelocationsonamap.Markerscanalsodisplaycustomiconimages Polyline-Seriesofstraightlinesonamap Polygon-Seriesofstraightlinesonamap,andtheshapeis"closed" CircleandRectangle InfoWindows-Displayscontentwithinapopupballoonontopofamap Customoverlays GoogleMaps-AddaMarker TheMarkerconstructorcreatesamarker.Notethatthepositionproperty mustbesetforthemarkertodisplay. AddthemarkertothemapbyusingthesetMap() method: Example varmarker=newgoogle.maps.Marker({position:myCenter}); marker.setMap(map); GoogleMaps-AnimatetheMarker Theexamplebelowshowshowtoanimatethemarkerwiththeanimationproperty: Example var marker=newgoogle.maps.Marker({ position:myCenter, animation:google.maps.Animation.BOUNCE }); marker.setMap(map); GoogleMaps-IconInsteadofMarker Theexamplebelowspecifiesanimage(icon)touseinsteadofthedefaultmarker: Example varmarker=newgoogle.maps.Marker({ position:myCenter, icon:'pinkball.png' }); marker.setMap(map); GoogleMaps-Polyline APolylineisalinethatisdrawnthroughaseriesofcoordinatesinanorderedsequence. Apolylinesupportsthefollowingproperties: path-specifiesseverallatitude/longitudecoordinatesfortheline strokeColor-specifiesahexadecimalcolorfortheline(format:"#FFFFFF") strokeOpacity-specifiestheopacityoftheline(avaluebetween0.0and1.0) strokeWeight-specifiestheweightoftheline'sstrokeinpixels editable-defineswhetherthelineiseditablebyusers(true/false) Example varmyTrip=[stavanger,amsterdam,london]; varflightPath=newgoogle.maps.Polyline({ path:myTrip, strokeColor:"#0000FF", strokeOpacity:0.8, strokeWeight:2 }); GoogleMaps-Polygon APolygonissimilartoaPolylineinthatitconsistsofa seriesofcoordinatesinanorderedsequence.However,polygonsaredesignedtodefineregionswithinaclosedloop. Polygonsaremadeofstraightlines,andtheshapeis"closed"(allthelines connectup). Apolygonsupportsthefollowingproperties: path-specifiesseveralLatLngcoordinatesfortheline(firstandlastcoordinateareequal) strokeColor-specifiesahexadecimalcolorfortheline(format:"#FFFFFF") strokeOpacity-specifiestheopacityoftheline(avaluebetween0.0and1.0) strokeWeight-specifiestheweightoftheline'sstrokeinpixels fillColor-specifiesahexadecimalcolorfortheareawithintheenclosedregion(format:"#FFFFFF") fillOpacity-specifiestheopacityofthefillcolor(avaluebetween0.0and1.0) editable-defineswhetherthelineiseditablebyusers(true/false) Example varmyTrip=[stavanger,amsterdam,london,stavanger]; varflightPath=newgoogle.maps.Polygon({ path:myTrip, strokeColor:"#0000FF", strokeOpacity:0.8, strokeWeight:2, fillColor:"#0000FF", fillOpacity:0.4 }); GoogleMaps-Circle Acirclesupportsthefollowingproperties: center-specifiesthegoogle.maps.LatLngofthecenterofthecircle radius-specifiestheradiusofthecircle,inmeters strokeColor-specifiesahexadecimalcolorforthelinearoundthecircle(format:"#FFFFFF") strokeOpacity-specifiestheopacityofthestrokecolor(avaluebetween0.0and1.0) strokeWeight-specifiestheweightoftheline'sstrokeinpixels fillColor-specifiesahexadecimalcolorfortheareawithinthecircle(format:"#FFFFFF") fillOpacity-specifiestheopacityofthefillcolor(avaluebetween0.0and1.0) editable-defineswhetherthecircleiseditablebyusers(true/false) Example varmyCity=newgoogle.maps.Circle({ center:amsterdam, radius:20000, strokeColor:"#0000FF", strokeOpacity:0.8, strokeWeight:2, fillColor:"#0000FF", fillOpacity:0.4 }); GoogleMaps-InfoWindow ShowanInfoWindowwithsometextcontentforamarker: Example varinfowindow=newgoogle.maps.InfoWindow({ content:"HelloWorld!" }); infowindow.open(map,marker); ❮Previous Next❯ NEW WejustlaunchedW3Schoolsvideos Explorenow COLORPICKER Getcertifiedbycompletingacoursetoday! w3schoolsCERTIFIED.2022 Getstarted CODEGAME PlayGame
延伸文章資訊
- 1Markers | Maps JavaScript API - Google Developers
// In the following example, markers appear when the user clicks on the map. // Each marker is la...
- 2The No Code Custom Google Maps Marker Icons With Colors ...
Even better, most of these examples require absolutely zero code. Easy Single Color Marker Maps. ...
- 3遊記ep.28 Marker labels in Google村 - iT 邦幫忙
var image = 'https://developers.google.com/maps/documentation/javascript/ ... In the following ex...
- 4Google Maps JS API v3 - Simple Multiple Marker Example
Fairly new to the Google Maps Api. I've got an array of data that I want to cycle through and plo...
- 5Google Maps JavaScript API v3 Tutorial - UMIACS
The following example adds a simple marker to a Google Map at the Van Munching Hall: map.js. func...