Overview | Maps JavaScript API - Google Developers
文章推薦指數: 80 %
function initMap(): void { map = new google.maps.Map(document.getElementById("map") as HTMLElement, { center: { lat: -34.397, lng: 150.644 }, zoom: 8, }); Google MapsPlatform Overview Products Pricing Documentation GetStarted GetStartedwithGoogleMapsPlatform APIPicker Billing&Pricing Reporting&Monitoring MapIDs FAQ SupportandResources IncidentManagement Maps MapsJavaScriptAPI MapsSDKforAndroid MapsSDKforiOS MapsStaticAPI StreetViewStaticAPI MapsEmbedAPI MapsURLs MapsElevationAPI Routes DirectionsAPI DistanceMatrixAPI RoadsAPI Solutions IndustrySolutions GamingServices TransportationandLogistics Places PlacesAPI PlacesSDKforAndroid PlacesSDKforiOS PlacesLibrary,MapsJavaScriptAPI GeocodingAPI GeolocationAPI TimeZoneAPI AdditionalResources APISecurityBestPractices MapCoverageDetails OptimizationGuide MobileOSandsoftwaresupport Launchstages Deprecations AssetTrackingPlan URLEncoding WordPressUsers Blog Community StackOverflow GitHub YouTube Discord Twitter IssueTracker English BahasaIndonesia Deutsch Español Español–AméricaLatina Français Italiano Polski Português–Brasil TiếngViệt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文–简体 中文–繁體 日本語 한국어 Signin Web MapsJavaScriptAPI GetStarted Contactsales Guides Reference Samples Support Google MapsPlatform Overview Products Pricing Documentation More Guides Reference Samples Support Blog Community More MapsJavaScriptAPI Overview SetupinCloudConsole UsingAPIKeys Tutorials Alltutorials Addamarkertoyourmap Clustermarkers Real-timecollaborativemapping Showcurrentlocation Usedatawithyourmap DisplayingKMLImportingJSONdataVisualizingJSONdataCombiningJSONdata AddingaMapandMarkerstoaReactApplication Concepts Allconcepts Maptypes Mapandtilecoordinates Localizingthemap Versioning URLparameters Bestpractices UsingTypeScript Promises Managemarkerlabelcollisions Customizeamap CustomizewithCloud-basedmapsstyling OverviewMapStyleEditorwalkthroughManagemapstylesWorkwithzoomlevelsCustomizePOIbehaviorCustomizebuildingstyleStylingexamplesDesignchecklist CustomizewithJSONstyling JSONstylingoverviewJSONstylereference CustomLegends Interactwiththemap Controls Events Controlzoomandpan Drawonthemap Overview Markers Custommarkers Infowindows Shapes Symbols WebGLFeatures OverviewSupportVectorMapsTiltandRotationWebGLOverlayView Deck.gldatavisualizations Groundoverlays Customoverlays Displaydata Overview Data-drivenstyling(Preview) OverviewGetstartedStyleaboundarypolygonMakeachoroplethmapHandleclickeventsUsetheRegionLookupAPIUsetheRegionLookupAPIwithGoogleSheetsUseGeocodingandPlacesAPIswithData-drivenstylingGoogleboundariescoverage Datalayer Heatmap KMLandGeoRSS Traffic,Transit,andBicyclingLayers Services Directions DistanceMatrix Elevation Geocoding MaximumZoomImagery StreetView Libraries Overview DrawingLibrary GeometryLibrary LocalContextLibrary(Beta) OverviewGetStartedSettingLocalContextandMapOptionsHandlingEventsandUserInteractionRefreshingSearchPropertiesStylingtheLocalContextMapViewSupportedPlaceTypesMigratingaMaptoLocalContextMapView PlacesLibrary PlaceAutocomplete VisualizationLibrary OpenSourceLibraries MoreGuides ContentSecurityPolicyGuide GoogleLoaderMigrationGuide PlaceFieldMigration(open_now,utc_offset) PlaceDataFields PlaceIcons PlaceIDs PlaceTypes Upgradingfromv2tov3 PoliciesandTerms Usageandbilling Reportingandmonitoring Termsofservice OtherAPIs MapsStaticAPI StreetViewStaticAPI MapsEmbedAPI MapsURLs GetStarted GetStartedwithGoogleMapsPlatform APIPicker Billing&Pricing Reporting&Monitoring MapIDs FAQ SupportandResources IncidentManagement Maps MapsJavaScriptAPI MapsSDKforAndroid MapsSDKforiOS MapsStaticAPI StreetViewStaticAPI MapsEmbedAPI MapsURLs MapsElevationAPI Routes DirectionsAPI DistanceMatrixAPI RoadsAPI Solutions IndustrySolutions GamingServices TransportationandLogistics Places PlacesAPI PlacesSDKforAndroid PlacesSDKforiOS PlacesLibrary,MapsJavaScriptAPI GeocodingAPI GeolocationAPI TimeZoneAPI AdditionalResources APISecurityBestPractices MapCoverageDetails OptimizationGuide MobileOSandsoftwaresupport Launchstages Deprecations AssetTrackingPlan URLEncoding WordPressUsers StackOverflow GitHub YouTube Discord Twitter IssueTracker Home Products GoogleMapsPlatform Documentation Web MapsJavaScriptAPI Sendfeedback Overview Stayorganizedwithcollections Saveandcategorizecontentbasedonyourpreferences. Selectplatform: Android iOS JavaScript Beforeyoubegin: BeforeyoustartusingtheMapsJavaScriptAPI,youneedaprojectwithabillingaccountandthe MapsJavaScriptAPI enabled.WerecommendcreatingmultipleProjectOwnersandBillingAdministrators,sothat you'llalwayshavesomeonewiththeserolesavailabletoyourteam.Tolearnmore,see SetupinCloudConsole. TheMapsJavaScriptAPIletsyoucustomizemapswithyourowncontentand imageryfordisplayonwebpagesandmobiledevices.TheMapsJavaScriptAPI featuresfourbasicmaptypes(roadmap,satellite,hybrid,andterrain)whichyoucan modifyusinglayersandstyles,controlsandevents,andvariousservicesandlibraries. Audience Thisdocumentationisdesignedforpeoplefamiliarwith JavaScriptprogrammingandobject-orientedprogrammingconcepts.You shouldalsobefamiliarwithGoogle Mapsfromauser'spointofview.Therearemany JavaScript tutorialsavailableontheWeb. Thisconceptualdocumentationisdesignedtoletyouquicklystart exploringanddevelopingapplicationswiththeMapsJavaScriptAPI.Wealso publishtheMapsJavaScriptAPIReference. Hello,World TheeasiestwaytostartlearningabouttheMapsJavaScriptAPI istoseeasimpleexample.Thefollowingexampledisplaysamapcenteredon Sydney,NewSouthWales,Australia. TypeScript letmap:google.maps.Map; functioninitMap():void{ map=newgoogle.maps.Map(document.getElementById("map")asHTMLElement,{ center:{lat:-34.397,lng:150.644}, zoom:8, }); } declareglobal{ interfaceWindow{ initMap:()=>void; } } window.initMap=initMap;index.ts Note:ReadtheguideonusingTypeScriptandGoogleMaps. JavaScript letmap; functioninitMap(){ map=newgoogle.maps.Map(document.getElementById("map"),{ center:{lat:-34.397,lng:150.644}, zoom:8, }); } window.initMap=initMap;index.js Note:TheJavaScriptiscompiledfromtheTypeScriptsnippet. CSS /* *Alwayssetthemapheightexplicitlytodefinethesizeofthedivelement *thatcontainsthemap. */ #map{ height:100%; } /* *Optional:Makesthesamplepagefillthewindow. */ html, body{ height:100%; margin:0; padding:0; } style.css HTML
延伸文章資訊
- 1message: initMap is not a function - CodeRanch
In your url you told Maps that you had a callback named initMap that you wanted it to call. But y...
- 2initMap 不是函數” (Google Maps API Error - CoderBridge
問題描述Google Maps API 錯誤:“initMap 不是函數” (Google Maps API Error: "initMap is not a function") 我收到Goo...
- 3Connecting Google Maps API on the any sites - gists · GitHub
initMap() - функция инициализации карты. function initMap() {. // Координаты центра на карте. var...
- 4遊記ep.21 Event in Google村 - iT 邦幫忙
html, body { height: 100%; margin: 0; padding: 0; } </style> </head> <body> <div id="map"></div> ...
- 5Step-by-step Guide On Calling Google Map Javascript API For ...
Create initMap() function in another script tag where you will use the google.maps.Map and google...