Original address
Google Maps JavaScript Official document: https://developers.google.com/maps/documentation/javascript/
Before creating the map, we entered Google developers console to create a key for our development of the map authentication (of course, no key can also be carried out in the next tutorial)
To create a simple map:
<! DOCTYPE html>If you do not have a key, you can remove the code "KEY=YOUR_API_KEY&CALLBACK=INITMAP" </script> <script src= "https:// Maps.googleapis.com/maps/api/js?key=your_api_key&callback=initmap "Async defer></script> </body > |
Using the code above, you can create a map.
If you can't access your Google server because of a network problem, you can change "maps.googleapis.com/maps/api/js" to "Maps.google.cn/maps/api/js" and try
to create a map's constructor prototype: Map (mapdiv:node,opts?:mapoptions)
The center and zoom in the code above are the two attributes in Mapoptions, which are more commonly used:
Draggable:bool type to control whether the map can be dragged
Maptypeid: Hybrid/roadmap/satellite/terrain, four types of maps, you can try the effect on your own
Maptypecontrol:bool type, whether to display controls that can change the map type
Maxzoom: Set map maximum zoom level
Minzoom: set map minimum zoom level
Zoomcontrol:bool type, whether to display a control that can change the size of the map
Google Maps JS V3 API tutorial (1)--Create a map