Baidu Map API Custom Callout icon

Source: Internet
Author: User

The icon class allows you to implement custom labels, and the following example is set by the icon property of the parameter markeroptions.
You can also use the Marker.seticon () method.

<script type="Text/javascript">//Baidu Map API function    varMap =NewBmap.map ("Allmap");//Create a map instanceMap.centerandzoom (NewBmap.point (116.323066,39.989956), -);//Initialize map, set center point coordinates and map levelMap.addcontrol (NewBmap.maptypecontrol ());//Add a map type controlMap.setcurrentcity ("Beijing");//Set map to show the city this entry is mandatoryMap.enablescrollwheelzoom (true);//Turn on mouse wheel zoom    varpoints = [[116.316967,39.990748],        [116.323938,39.989919],        [116.328896,39.988039],        [116.321135,39.987072],        [116.332453,39.989007],        [116.324045,39.987984],        [116.322285,39.988316],        [116.322608,39.986381]    ];//Add labels to the map     for(vari =0; i < points.length; i++) {varMyicon =NewBmap.icon ("Http://7xic1p.com1.z0.glb.clouddn.com/markers.png",NewBmap.size ( at, -), {//Specify positioning locationOffsetNewBmap.size (Ten, -),//When you need to intercept a section from a larger picture as a callout icon, you need to specify the offset position of the large imageImageoffset:NewBmap.size (0,0I -)//Set picture offset});varPoint =NewBmap.point (points[i][0],points[i][1]);//Create dimension object and add to map        varMarker =NewBmap.marker (Point,{icon:myicon});    Map.addoverlay (marker); };</script>

Pictures used:

Demo Address: click

Itmyhome

Baidu Map API Custom Callout icon

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.