Google Maps API-1. Load Google Map

Source: Internet
Author: User
<  Html  > 
< Head >
< Title > Load Google Map </ Title >
< Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" />
< Script
SRC = "Http://ditu.google.com/maps? File = API & amp; V = 2 & amp; Key = ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA & HL = ZH-CN"
Type = "Text/JavaScript" > </ Script >

< Script Type = "Text/JavaScript" >
Function Load (){
// Check the compatibility of the browser.
If (Gbrowseriscompatible ())
{
// Load Map
VaR Map = New Gmap2 (document. getelementbyid ( " Mapcanvas " ));
// Set the central coordinates of the map. (glatlng (longitude, latitude), zoom leavel)
// Zoom leavel (maxvalue = 1, the greater the value, the smaller the zoom leavel)
Map. setcenter ( New Glatlng ( 39.990168 , 116.295304 ), 5 );
// Map. setcenter (New glatlng (23.352697196375434, 103.4267520904541), 18 );
}
}
</ Script >
</ Head >
< Body Onload = "Load ()" OnUnload = "Gunload ()" >
<! -- Map canvas -->
< Div ID = "Mapcanvas" Style = "Width: 800px; Height: 600px" > </ Div >
</ Body >
</ Html >

2. Set general attributes of a map

(1) map. continuouszoomenabled () -- determine whether the map supports Continuous scaling;

Map. enablecontinuouszoom ()/map. disablecontinuouszoom () method to switch whether Continuous scaling is allowed;

(2) scroll wheel scaling -- map. enablescrollwheelzoom ()/map. disablescrollwheelzoom ()

(3) double-click zoom -- map. enabledoubleclickzoom ()/map. disabledoubleclickzoom ()

(4) map dragging (default) -- draggingenabled () determines whether a map can be dragged, enabledragging ()/disabledragging ()

(5) Information Window-a bubble annotation can be displayed on the map to display information. infographic wenabled () Judgment, enableinfowindow ()/disableinfowindow

(6) Add a search bar

3. Map type

Map. setmaptype (g_satellife_map );// Modify the map type to a satellite map

Hybrid map --G_hybrid_mapDefault Value --G_nomal_map

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.