Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click event - onLayerClick #1464

Closed
openlayers-droid opened this issue Apr 27, 2021 · 6 comments
Closed

Click event - onLayerClick #1464

openlayers-droid opened this issue Apr 27, 2021 · 6 comments
Assignees

Comments

@openlayers-droid
Copy link

Thank you for the great tool!

an example on how to fire click events using onLayerClick is very much needed. i tried to hook up with MapBoxGL click event but it is not working - only zoomend/zoonstart events are firing.

many thanks

@openlayers-droid
Copy link
Author

i found that some people were looking for this, after some research i came up with the following:
app-reducer.js
const appReducer = handleActions( { [INIT]: (state, action) => ({ ...state, loaded: true }), [ActionTypes.LAYER_CLICK]: (state,info) => { console.log("info",info) return {...state} }, },

it is working for me, but i am not too sure of this is the right way.

@openlayers-droid
Copy link
Author

app-reduce.js

const appReducer = handleActions( { [INIT]: (state, action) => ({ ...state, loaded: true }), [ActionTypes.LAYER_CLICK]: (state,info) => { console.log("info",info) return {...state} }, },

@SincerelyUnique
Copy link

app-reduce.js

const appReducer = handleActions( { [INIT]: (state, action) => ({ ...state, loaded: true }), [ActionTypes.LAYER_CLICK]: (state,info) => { console.log("info",info) return {...state} }, },

Hi, openlayers-droid, thanks for your help so much, and could you share the detail usage here? :)

@SincerelyUnique
Copy link

Cool, thank you so so so much~ now I can get the click info, let me check the data
image

image

@SincerelyUnique
Copy link

image

image

it seems these properties can not be get from the LAYER_CLICK action, do you know which action support to get these infomation? I want to get the modal information when I click the point in the map.

@SincerelyUnique
Copy link

for my question, I find a solution, we can see the index:100 from my F12 dev console, it is the data index which I set from addDataToMap action, by the way , I send the geoJsonDataArray, so here 100 is my data array index, I can use the index to find the actual data (eg: geojson properties)

This was referenced Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants