Click to display high moral map information window on point mark

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_34664239/article/details/90374756

Covering the design of high moral map of this event Event Systems - Information window opens closing event
official Example: https://lbs.amap.com/api/javascript-api/example/event-overlay/infowindow-event

1. Markup

General need to display the title text and icons on the map when the text would mark not only text, but also can add icons, and maker mark, can only display the same

new AMap.Text
new AMap.Text({
	map: map,
	text: 'marker.content',
	position:  [116.473188,39.993253],
	offset: new AMap.Pixel(-18, -25),
	shadow: new AMap.Icon({
	    size: new AMap.Size(20, 10),
	    image: 'https://app.ilulala.cn/images/carIcon/car.png',
	    imageSize: new AMap.Size(20, 10)
	})
})

2. Information Window

AMap.event.addListener(item, 'click', function () {
	//创建信息窗口
    infoWindow = new AMap.InfoWindow({
        isCustom: true,  //使用自定义窗体
        content: '信息的html代码字符串',
        offset: new AMap.Pixel(-15, -25)
    });
    //打开信息窗口
    infoWindow.open(map, [116.473188,39.993253]); //后面的参数指的是经纬度,在此显示窗口
});

Guess you like

Origin blog.csdn.net/qq_34664239/article/details/90374756