ImageLayer
AMap.ImageLayer
Image layer class, users can add a static image as a layer on the map, and the image layer will adaptively scale with the zoom level. Construct an ImageLayer object and set the layer properties through ImageLayerOptions
new AMap.ImageLayer(opts: ImageLayerOptions)Parameter
opts(ImageLayerOptions): Image layer parameters
Demo
//Create Image Layer
var imageLayer = new AMap.ImageLayer({
url: "https://amappc.cn-hangzhou.oss-pub.aliyun-inc.com/lbs/static/img/dongwuyuan.jpg", //Image URL
bounds: new AMap.Bounds([116.327911, 39.939229], [116.342659, 39.946275]), //Latitude and longitude of the image extent, pass in the southwest and northeast latitude and longitude coordinates
zIndex: 2, //Layer hierarchy
zooms: [15, 20], //Set visibility level, [min level, max level]
});Method
setImageUrl(url)
Set the image URL
Parameter: url (String) Image URL
Demo:
imageLayer.setImageUrl("https://amappc.cn-hangzhou.oss-pub.aliyun-inc.com/lbs/static/img/dongwuyuan.jpg");getBounds()
Get the display range of ImageLayer
return value: (Bounds) Latitude and longitude range values
Demo:
imageLayer.getBounds();setBounds(Bounds)
Set the display range of ImageLayer
Parameter: Bounds(Bounds) Image Area Size and Coordinates
Demo:
imageLayer.setBounds(new AMap.Bounds([116.327911, 39.939229], [116.342659, 39.946275]));getOptions()
Get Layer Parameter Information
return value: (Object) Layer Parameter Information
Demo:
imageLayer.getOptions();setzIndex(zIndex)
Set layer level, the higher the number the higher the layer level
Parameter: zIndex (Number) Layer level value
Demo:
imageLayer.setzIndex(10);getOpacity()
Get layer opacity
return value: (Number) opacity layer transparency
Demo:
imageLayer.getOpacity();setOpacity(opacity)
Set layer opacity, range [0 ~ 1], where 1 represents completely opaque and 0 represents completely transparent
Parameter: opacity (Number) Layer transparency
Demo:
imageLayer.setOpacity(0.5);getZooms()
Get the zoom level range at which this layer can be displayed, with a default range of [2-20]
return value: ([Number, Number]) The zoom level range at which this layer can be displayed
Demo:
imageLayer.getZooms();setZooms(zooms)
Set the zoom level range at which this layer can be displayed
Parameter: zooms([Number, Number]) The zoom range at which this layer can be displayed
Demo:
imageLayer.setZooms([8,12]);show()
Show Layer
Demo:
imageLayer.show();hide()
Hide Layer
Demo:
imageLayer.hide();Event
For event object property descriptions, go to:MapsEvent