Access Layer on click event

2337
2
Jump to solution
04-22-2016 05:21 AM
TimWitt2
MVP Alum

Hey everybody,

is there a way to access the on click event of the layer that I use in my journal map?

Thanks,

Tim

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
GregoryL_Azou
Occasional Contributor III

Yes, you can access the maps included in your Journal through the app.maps object, for example

app.maps['27e642041b9a498e9d9253b20a5a7d44'].response.map

will give you access to the map object of web map with the specific id

Then you can use any method of the ArcGIS API for JavaScript.

Note that app.maps is only populated when you navigate to the the section containing it.

So you have to listen to a map load before placing your click listener

// After a map is loaded (when the map starts to render)  
topic.subscribe("story-loaded-map", function(result){
   console.log("The map", result.id, "has been loaded");
   app.maps[result.id].response.map...
});

This code can be placed in index.html after this line map-journal-storytelling-template-js/index.html at master · Esri/map-journal-storytelling-template-j...

More information about customization at GitHub - Esri/map-journal-storytelling-template-js: The Story Map Journal is ideal when you want to ...

View solution in original post

2 Replies
GregoryL_Azou
Occasional Contributor III

Yes, you can access the maps included in your Journal through the app.maps object, for example

app.maps['27e642041b9a498e9d9253b20a5a7d44'].response.map

will give you access to the map object of web map with the specific id

Then you can use any method of the ArcGIS API for JavaScript.

Note that app.maps is only populated when you navigate to the the section containing it.

So you have to listen to a map load before placing your click listener

// After a map is loaded (when the map starts to render)  
topic.subscribe("story-loaded-map", function(result){
   console.log("The map", result.id, "has been loaded");
   app.maps[result.id].response.map...
});

This code can be placed in index.html after this line map-journal-storytelling-template-js/index.html at master · Esri/map-journal-storytelling-template-j...

More information about customization at GitHub - Esri/map-journal-storytelling-template-js: The Story Map Journal is ideal when you want to ...

TimWitt2
MVP Alum

Thanks!

0 Kudos