Google Maps API-2. Control Map

Source: Internet
Author: User

1. Map zoom control

(1) All-Around control-glargemapcontrol

(2) miniature controls-gsmallmapcontrol

(3) miniature scaling control-gsmallzoomcontrol

2. Map Type Selection Control

(1) gmaptypecontrol

(2) Menu Control-gmenutypecontrol

(3) standard class control-ghierarchicalmaptypecontrol

3. Thumbnail Control -- goverviewmapcontrol

4. Scale Control-gscalecontrol

How to add controls:

Map. addcontrol (New glargemapcontrol ());

Map. addcontrol (New glargemapcontrol (),New gcontrolposition (g_anchor_bottom_right, new gsize (10, 10 )));

Gcontrolposition: an optional parameter;

 

 <  Html  > 
< Head >
< 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.
Map. setcenter ( New Glatlng ( 39.990168 , 116.295304 ), 4 );
// Allows users to move and scale a map
Map. addcontrol ( New Gsmallmapcontrol ());
// Allows users to switch between map types
Map. addcontrol ( New Gmaptypecontrol ());
}
}
</ Script >
</ Head >
< Body Onload = "Load ()" OnUnload = "Gunload ()" >
<! -- Map canvas -->
< Div ID = "Mapcanvas" Style = "Width: 640px; Height: 480px" > </ Div >
</ Body >
</ Html >


 

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.