How does the "Gold Map API" Set the icon's imagesize?

Source: Internet
Author: User

In map development, we need to change the labels to a variety of images to highlight the personality.

Under high-resolution phones, the picture size needs to be compressed to half to keep the picture clear. Let's take a look at how it should be done.

In order to change the size of the picture, a developer directly wrote

ImageSize: (64, 64)

Or

ImageSize: "64px 64px"

Is there a problem?

First look at the ImageSize class reference and see the type is size.

size is the type of the German API customization , not Num. Therefore, it is wrong to write the numbers directly.

Then the correct wording should be:

New Amap.size (64,64)

On high-resolution displays, you should compress the dimensions in half. Compared to the film size is 128*128, then imagesize need to compress the picture half, should be 64*64. The code is as follows:

    // add point markers and use your own icon    New Amap.marker ({        map:map,        position: [116.47395,39.986058],        new  Amap.icon ({                        "marker128.png",            new amap.size (+),  // icon size            New Amap.size (64,64)})            ;

Demo Address: http://zhaoziang.com/amap/imageSize.htm

All sample code:

<!doctype html>//Initialize map object, load Map    varMap =NewAmap.map ("Container", {resizeenable:true, Zoom:11    }); //add point markers and use your own icon    NewAmap.marker ({map:map, Position: [116.47395,39.986058], Icon:NewAmap.icon ({image:"Marker128.png", Size:NewAmap.size (128, 128),//icon SizeImageSize:NewAmap.size (64,64)        })            }); //add point markers and use your own icon    NewAmap.marker ({map:map, Position: [116.321514,39.91289], Icon:NewAmap.icon ({image:"Marker128.png", Size:NewAmap.size (128, 128),//icon SizeImageSize:NewAmap.size (128,128)        })            });</script></body>

How does the "Gold Map API" Set the icon's imagesize?

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.