Mouse click on map Store Map

46 views
Skip to first unread message
Assigned to lorenzo...@geosolutionsgroup.com by me

himanshu tambe

unread,
Jul 28, 2021, 12:20:17 PM7/28/21
to mapstore-developers
Hi 

I am handling the click on the Map. (Map Store).
I am getting the Point info (x, y and lat, lng...etc.).... the issue is Layer is coming as undefined.

Please see the below screen shot........

click.PNG

Lorenzo Natali

unread,
Jul 29, 2021, 5:19:29 AM7/29/21
to mapstore-developers
Hi,
layer is passed only if `handleClickOnLayer` property of the layer is true.

It is actually used only for some  special vector layers (annotations).

Lorenzo Natali

unread,
Jul 30, 2021, 3:48:54 AM7/30/21
to mapstore-developers
Please send the questions to the whole group,

Here your previous email
===========================================================
With your suggestion now ..I am getting the layer ID in the action object.
Can we handle the mouse click on base map and WMS layers ?

Sorry, I have 2 more Q.
1. How to  handle the MouseMove 
2. How to handle the Feauter Click Info
===========================================================

> With your suggestion now ..I am getting the layer ID in the action object.
Yes as I said this is a very special feature, that may be not so useful.


1) mouse move
At the moment to handle mouse move you have to send the action 
registerEventListener('mousemove', 'MyTool') and  unRegisterEventListener('mousemove', 'MyTool') to start and stop .
When the event listener is registered, you will see actions triggering while the mouse moves on the map (this registration is make only for mouse move, in order to avoid to many actions to be triggered without any reason)


2) Handle feature click info
You can use the info in the CLICK_ON_MAP to do your ajax call. There are some utility functions in the web/client/api/identify


himanshu tambe

unread,
Aug 3, 2021, 1:49:12 AM8/3/21
to mapstore-developers
Thanks for responses so far...that helped.

I have handled the Mouse move, it is working but I am also getting the error in the console .... any one has any idea to fix it. 

Error in epic "mouseMoveMapEventEpic". Original error: TypeError: Cannot read property 'mouseOut' of undefined
    at t.project (ms2-api.js:134)
    at t._next (ms2-api.js:125)
    at t.next (ms2-api.js:125)
    at t.debouncedNext (ms2-api.js:125)
    at t.l (ms2-api.js:125)
    at t._execute (ms2-api.js:125)
    at t.execute (ms2-api.js:125)
    at t.flush (ms2-api.js:125)
    at timer (zone-evergreen.js:2561)
    at ZoneDelegate.invokeTask (zone-evergreen.js:406)

This is how, I have implemented it...
MapStore2.triggerAction({
    eventName: "mousemove",
    toolName: "mouseposition",
    type: "REGISTER_EVENT_LISTENER"
  })
 

    MapStore2.onAction('MOUSE_MOVE', function(action) {
      console.log('MOUSE_MOVE: ', action);
    });

Lorenzo Natali

unread,
Aug 6, 2021, 12:11:37 PM8/6/21
to mapstore-developers
Looking at the error, it seems that have been fixed contextually with this issue and it should be available in the next stable release.
You can try the master to verify it works.

Reply all
Reply to author
Forward
0 new messages