Call the api, of Amap js to add a click event to the dot tag

add a click event to Amap"s dot mark in the project. For more information, please see the following code:
1. Create a dot tag

new AMap.Marker ({
icon: icon,//24px*26px
position: vue.customer [I] .position,
title: vue.customer [I] .name,
zIndex: 200,
clickable: true,
map: map
});

2. Add a click event to the dot tag

var clickHandle = AMap.event.addListener (marker, "click", function () {
console.log ("1111")
});

3. Click and report an error

marker is not defined

Apr.01,2021

I haven't played Gaud API, but I can guess the cause of the problem by looking at your code: marker is not defined. It is inferred that the previous new instance should be assigned to marker

var marker = new AMap.Marker({
                icon: icon,//24px*26px
                position: vue.customer[i].position,
                title: vue.customer[i].name,
                zIndex: 200,
                clickable: true,
                map: map
               });
               
var clickHandle = AMap.event.addListener(marker, 'click', function() {
                                                            console.log("1111")
                                                          });              

marker is not defined

marker corresponds to the tag entity you want to control.

Menu