Click on map

3149
1
11-17-2015 06:21 AM
JanneEriksson
New Contributor

My task is to create a custom widget in OD where the user will click on map to choose a region. I thought of using a spatial query to fetch the id of the region and later fetch more information from a separate table. But I cannot figure out how to set the click-event on dataSource or another object representing the map.

Something like:

this.dataSourceProxy.on("click", function() {...

but it doesn't work.

Also I tryed to create MapWidgetProxy-object but didn't succeed.

Somebody done this before and can give a hint? I'm stuck.

//Janne

0 Kudos
1 Reply
NoppadonHimananto
New Contributor II

As I know, there are only map-extent-change event for map.

but there are another way to go with your requirement. (May not complete)

First, this sample may help you.

it will list attribute of select feature from selected datasource on widget when user select feature on map.

So, in widget config. let user select region layer with selected option as DataSource.

In main widget java-script, use data-source-expired event to capture when user select region on your map.

dataSourceExpired: function (dataSource, dataSourceConfig) {
     //this event will be fired every time that user select region on map.
}

Second way is create widget that let user draw some point to map then query to find region layer with that point.

On this way ,if you decide to query with QueryTask ​, you must fix url of service in code and may encounter with CORS ​, So you may

need proxy here, But I can't find any sample that work with proxy.

Well, you still can use ExecuteQuery of datasource instead to avoid CORS ​probs.

But again, ExecuteQuery with geometry's parameter work well in desktop. In browser geometry's parameter was ignore.

this may be bug and you may not complete you solution in browser.