Bug neoMapMarkerEvent - Forum

Forum Navigation
You need to log in to create posts and topics.

Bug neoMapMarkerEvent

luishp Greetings!

I am creating a shipping map using neoMap, with various shipping zones organized using the neoMapAddPolygon command. I need to get the name of the delivery zone where the click was made, but the neoMapMarkerEvent command is not working. The neoMapMarkerEvent command in main.js is interpreted as a neoMapMakerEvent.

As a result, these parameters don't work for me:

neoMapMarkerEvent "mapContainer" "zone1" "click" "getCoordinates"

OR

beginJS
function neoMapMakerEvent(containerId,mname,eventName,subroutine){
    $App[containerId+mname+"neoMapObject"].on(eventName,function(e){
    console.log(e);
    lat=e.target._latlng.lat;lng=e.target._latlng.lng;subroutine(lat,lng,mname);});}

neoMapMakerEvent('mapContainer', 'zone1', 'click', $scope.getCoordinates);
endJS


//error in the console
Uncaught TypeError: Cannot read properties of undefined (reading 'lat')

This solution turned out to be a working solution for me:

function neoMapMakerEvent(containerId, mname, eventName, subroutine) {
        $App[containerId + mname + "neoMapObject"].on(eventName, function(e) {
            var lat = e.latlng ? e.latlng.lat : e.target._latlng.lat;
            var lng = e.latlng ? e.latlng.lng : e.target._latlng.lng;
            subroutine(lat, lng, mname);
        });
    }

neoMapMakerEvent('mapContainer', 'zone1', 'click', $scope.getCoordinates);

 

luishp has reacted to this post.
luishp

Thank you @alexander_loc
I will try to fix it asap :)

alexander_loc has reacted to this post.
alexander_loc