How do I change the Google Maps draggable property for the ...

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

I have set the property draggable to false in the mapOptions, but I don't know how to set this to true later... map.setDraggable(true) does not work: // object ... OnlydayslefttoRSVP!JoinusSept28atourinauguralconference,everyoneiswelcome. Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. LearnmoreaboutCollectives Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. LearnmoreaboutTeams HowdoIchangetheGoogleMapsdraggablepropertyforthemap(notthemarker)? AskQuestion Asked 9years,9monthsago Modified 6years,5monthsago Viewed 31ktimes 15 1 IntheGoogleMapsv3reference,IseethereisamethodsetDraggable(boolean)whichcanbeappliedtoamapmarker. However,IwanttosetsetDraggabletotrueonthemap,notonamapmarker. IhavesetthepropertydraggabletofalseinthemapOptions,butIdon'tknowhowtosetthistotruelater... map.setDraggable(true)doesnotwork: //objectliteralformapoptions varmyOptions= { center:newgoogle.maps.LatLng(37.09024,-95.712891), zoom:4,//smallernumber-->zoomout mapTypeId:google.maps.MapTypeId.TERRAIN, //removingallmapcontrols disableDefaultUI:true, //preventsmapfrombeingdragged draggable:false, //disablingallkeyboardshortcuts keyboardShortcuts:false, disableDoubleClickZoom:true, //donotclearthemapdiv noClear:true }; map=newgoogle.maps.Map(document.getElementById("map_canvas"),myOptions); map.setDraggable(true);//doesNOTwork! google-maps-api-3draggable Share Improvethisquestion Follow askedDec18,2012at16:01 IanCampbellIanCampbell 2,6401010goldbadges5555silverbadges102102bronzebadges Addacomment  |  3Answers 3 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 24 Try: map.setOptions({draggable:true}); Share Improvethisanswer Follow answeredDec18,2012at16:04 MarceloMarcelo 9,31733goldbadges3434silverbadges4040bronzebadges 3 1 Thanks@Marcelo,thatdidthetrick!IwasnotawareofsetOptions,andhoweasyitistoaccessthemapoptionsthisway. – IanCampbell Dec18,2012at16:28 @Marcelo,thakyouverymuch! – user5718206 Dec20,2016at15:57 Thisisdeprecated.Seedevelopers.google.com/maps/documentation/javascript/… – Nicolas Jul27,2018at17:00 Addacomment  |  1 Ienteredmycodeinthissectionanditworkedonmobileanddesktop functioninitialize() { varmapProp={ center:myCenter, zoom:5, draggable:false, mapTypeId:google.maps.MapTypeId.ROADMAP }; Share Improvethisanswer Follow answeredJun10,2015at19:07 DarrylDarryl 1111bronzebadge Addacomment  |  0 setDraggableisnotusedintheMapclass. Itisusedinthe: MarkerClass, Polylineclass, Polygonclass, RectangleclassandintheCircleclass. Inyourcaseyoucansimplyuse: map.draggable=true; Share Improvethisanswer Follow answeredApr8,2016at13:32 gadlolgadlol 1,24322goldbadges1414silverbadges2323bronzebadges Addacomment  |  YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggedgoogle-maps-api-3draggableoraskyourownquestion. TheOverflowBlog Fiveninesuptimewithoutdeveloperburnout(Ep.488) WehateScrumandAgile…whenit’sdonewrong(Ep.489) FeaturedonMeta RecentColorContrastChangesandAccessibilityUpdates Revieweroverboard!Orarequesttoimprovetheonboardingguidancefornew... ShouldIexplainotherpeople'scode-onlyanswers? Related 570 HowtodisablemousescrollwheelscalingwithGoogleMapsAPI 714 GoogleMapsJSAPIv3-SimpleMultipleMarkerExample 43 GoogleMapsv3-Howtocenterusinganaddressoninitialize? 296 GoogleMapsAPI3-Custommarkercolorfordefault(dot)marker 5 GoogleMapsAPIv3won'tdisablescrollwheelaftermaploads 2 Redrawingmapbasedonlatandlonggooglemap 2 googlemapsrefreshinggrey 0 GoogleEarthAPIstopsupport? HotNetworkQuestions XeLaTeX:Combineacharacterwithanaccentmarkfromanotherfonttodealwithmissingglyphwithoutdefininganewcommand Unusualwordstodenoteaspecificlengthoftime?Likefortnightbutfordifferentamountsoftime IsthereasomewhatrealisticFOSSflightsimulatorforLinux? IsitpossibletoplayMinecraftwithoutmigratingmyMojangaccounttoaMicrosoftaccount? Recommendationletterandconflictofinterest Arrowtoanequalsymbolinaequationtojustifyit CanprofessorsarrangeforanMScscholarshipifyoucontactthembye-mailandtheyareinterestedinworkingwithyou? Whatexactlydidthe"UNFORMAT"MS-DOScommanddo? Dosuchgraphsexist? CoronatVirtusInCordeMea/VirtueReignsInMyHeart? Differencebetween"unreal"and"notreal" WhathappenedtoMariner2afteritflewbyVenus? Carrylessfactors Goddoesn'tgivewithbothhands Whatdoyoucallitwhenyouaresayingsomethingpalpablyuntrueonpurpose? CanTempestuousMagicbreakagrapple? Thesameflightticketgotmuchcheaperafewdayslater.Howcome? Whenacorkispulledoutofawinebottle,whydoestheinnerendoftenexpandmorethantheouterend? Howmanyinstancesofsomemathematicalobject(e.g.aninteger)arethere? mainwatersupply'sgroundingwires sSet-enrichedcategories,quasi-categoriesandthemodel-independenttheory Emailaddressesgivinginternetconnection Canasingletympanaleardetectthedirectionordistancefromwhichasoundcomes? Determiningtheproblemtype-VehicleRouting-Taskassignment morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?