Google Maps - Markers - Tutorialspoint
文章推薦指數: 80 %
Adding a Simple Marker. You can add a simple marker to the map at a desired location by instantiating the marker class and specifying the position to be marked ... Home CodingGround Jobs Whiteboard Tools Business Teachwithus GoogleMapsTutorial GoogleMaps-Home GoogleMaps-GettingStarted GoogleMaps-Types GoogleMaps-Zoom GoogleMaps-Localization GoogleMaps-UIControls GoogleMaps-Markers GoogleMaps-Shapes GoogleMaps-InfoWindow GoogleMaps-Symbols GoogleMaps-Events GoogleMapsResources GoogleMaps-QuickGuide GoogleMaps-UsefulResources GoogleMaps-Discussion SelectedReading UPSCIASExamsNotes Developer'sBestPractices QuestionsandAnswers EffectiveResumeWriting HRInterviewQuestions ComputerGlossary WhoisWho GoogleMaps-Markers Advertisements PreviousPage NextPage Wecandrawobjectsonthemapandbindthemtoadesiredlatitudeandlongitude.Thesearecalledoverlays.GoogleMapsprovidesvariousoverlaysasshownbelow. Markers Polylines Polygons Circleandrectangle Infowindow Symbols Tomarkasinglelocationonthemap,GoogleMapsprovidesmarkers.Thesemarkersuseastandardsymbolandthesesymbolscanbecustomized.Thischapterexplainshowtoaddmarkers,andhowtocustomize,animate,andremovethem. AddingaSimpleMarker Youcanaddasimplemarkertothemapatadesiredlocationbyinstantiatingthemarkerclassandspecifyingthepositiontobemarkedusinglatlng,asshownbelow. varmarker=newgoogle.maps.Marker({ position:newgoogle.maps.LatLng(19.373341,78.662109), map:map, }); Example ThefollowingcodesetsthemarkeronthecityHyderabad(India). LiveDemo
Itproducesthefollowingoutput− AnimatingtheMarker Afteraddingamarkertothemap,youcangofurtherandaddanimationstoitsuchasbounceanddrop.Thefollowingcodesnippetshowshowtoaddbounceanddropanimationstoamarker. //Tomakethemarkerbounce` animation:google.maps.Animation.BOUNCE //Tomakethemarkerdrop animation:google.maps.Animation.Drop Example ThefollowingcodesetsthemarkeronthecityHyderabadwithanaddedanimationeffect− LiveDemo
Itproducesthefollowingoutput− CustomizingtheMarker YoucanuseyourowniconsinsteadofthedefaulticonprovidedbyGoogleMaps.Justsettheiconasicon:'ICONPATH'.Andyoucanmakethisicondraggablebysettingdraggable:true. Example Thefollowingexampleshowshowtocustomizethemarkertoadesiredicon− LiveDemo
Itproducesthefollowingoutput− RemovingtheMarker Youcanremoveanexistingmarkerbysettingupthemarkertonullusingthemarker.setMap()method. Example Thefollowingexampleshowshowtoremovethemarkerfromamap− LiveDemo
Itproducesthefollowingoutput− PreviousPage PrintPage NextPage Advertisements
延伸文章資訊
- 1Google Maps Marker - Happy Coding
This project uses the Google Maps API to create a map that shows a marker. View the code for this...
- 2Markers | Maps JavaScript API - Google Developers
// In the following example, markers appear when the user clicks on the map. // Each marker is la...
- 3Google 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...
- 4遊記ep.28 Marker labels in Google村 - iT 邦幫忙
var image = 'https://developers.google.com/maps/documentation/javascript/ ... In the following ex...
- 5Google Maps Overlays - W3Schools
Example. var marker = new google.maps.Marker({ position:myCenter, animation:google.maps.Animation...