Google Maps API beginner 2

Source: Internet
Author: User

From: http://hi.baidu.com/xfm_zhr/blog/item/7b963d085ac356d663d98648.html

8.Gmarker object

Used to mark the geographical location in a map. The specified location. The display information must depend on this object. Statement Syntax:

New gmarker (point, opts );

Point: the geographical location of the landmark, glatlng object.

Opts: a custom gmarker object, which can be omitted.

ExampleCode:

// Assign the glatlng () object to geopoint0, which is convenient for multiple times.

VaR geopoint0 = new glatlng (39.92, 116.46 );

Map. setcenter (geopoint0, 2 );

//Create a gmarker object

VaR marker0 = new gmarker (geopoint0 );

//Add a coating to marker0 on the map and display marker0

Map. addoverlay (marker0 );

 

Custom gmarker object

The OPTs parameter is used. It is generally considered as the gmarkeroptions class. It is actually an unknown class in JS and can change with the upgrade of API.

// JS unknown class

{

Property1: value1,

Property2, value2,

......

}

Sample Code of a typical custom gmarker object:

VaR marker1 = new gmarker (geopoint1 ,//Create a custom gmarker

{Icon: myicon,

Title :"Move the mouse up to see what "});

 

Gmarker. openinfowindowhtml (content, opts)

Displays ginfowindow information.

Content: HTML string.

Opts: ginfowindowoptions object, which can be omitted. It is also an anonymous class.

Gmarker. openinfowindow (content, opts)

Displays ginfowindow information.

Content: DOM object.

Opts: ginfowindowoptions object, which can be omitted. It is also an anonymous class.

 

Gmarker. openinfowindowtabshtml (tabs, opts)

The multi-Tag Information Window is displayed.

Tabs: The Tag Information Window array, where the ginfowindowtab object is created using an HTML string.

Opts: ginfowindwooptions object. Can be omitted.

Typical code:

// Create a ginfowindowtab Array

VaR tabs = [New ginfowindowtab ("tab1", "<Div style = 'width: 400px '> This is tab1 </div> "),

New ginfowindowtab ("tab2", "<Div style = 'width: 400px '> This is tab2 </div> "),

New ginfowindowtab ("tab3", "<Div style = 'width: 400px '> This is tab3 </div>")];

Marker. openinfowindowtabshtml (tabs );

 

Gmarker. openinfow.wtabs (tabs, opts)

The multi-tag window is displayed.

Tabs: The Tag Information Window array, where the ginfowindowtab object is created using the DOM object.

Opts: ginfowindwooptions object. Can be omitted.

 

9.Gicon object

Describes the objects of the icons on googlemaps.

Typical code:

//Create a custom gicon

VaR myicon = new gicon ();

//Foreground Image

Myicon. Image = "http://labs.google.com/ridefinder/images/mm_20_green.png ";

//Shadow Image

Myicon. Shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png ";

//Foreground image size, length x Width

Myicon. iconsize = new gsize (12, 20 );

//Shadow image size, length x Width

Myicon. shadowsize = new gsize (12, 20 );

//The following two attributes are hard to explain. Readers can adjust their values to understand their meanings.

// MyiconThe pixel distance between the anchor point and the upper left corner of the myicon Image

Myicon. iconanchor = new gpoint (6, 10 );

//The pixel distance between the information window and the upper left corner of the myicon Image

//The information window will be described later

Myicon. infographic wanchor = new gpoint (5, 1 );

 

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.