Google Maps - Markers - Tutorialspoint

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

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



請為這篇文章評分?