Can I highlight a selected feature in a map ?

1138
1
Jump to solution
06-23-2017 01:41 AM
GünterDörffel
Occasional Contributor III

Hi,

I have no problems adding a feature layer to a gis.map('MyMap') and then make a selection from that feature layer. I can zoom to the single feature fine, query its attributes, update, delete ... but there are two things I cant find that I would like to do

  • MOST perfect would be to open the defined popup for the feature immediately after zooming to it! (the get_html_popup doesnt do that, right?)
  • Second best would be to just select/highlight the feature in the map like I had interactively selected it in the map itself
  • Third best would be to add a label made up out of its attributes ...

I have too many features in a map extent to just change the extent ... I need to show the element better ..


Any help appreciated. I work in a jupyter notebook ...
Guenter

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
GünterDörffel
Occasional Contributor III

No comments so far - here my workaround if anyone stumbles across it:

I select the one feature I'd like to highlight using its ObjectID to create a "one-element-feature-set":

My_fset = MyLayer.query(where ='objectid = '+str(TheObjectID))

Now I can add that FeatureSet to the map as a draw-element and even (answer to my second question below) give it a basic popup:

For the popup I first need access to a feature (also there is only one in the Set):

My_feature = My_fset[0]

Now I can add it to the map and define the popup in one go

MyMap.draw(My_fset,{"title":"Popup-Title" , 'content': str(My_feature.attributes['field_a'])+" "+str(My_feature.attributes['field_b'])+': '+str(My_feature.attributes['field_c'])})

Hope this is helpful to anyone else - and still if there is an answer to my initial question - let me know :)

View solution in original post

1 Reply
GünterDörffel
Occasional Contributor III

No comments so far - here my workaround if anyone stumbles across it:

I select the one feature I'd like to highlight using its ObjectID to create a "one-element-feature-set":

My_fset = MyLayer.query(where ='objectid = '+str(TheObjectID))

Now I can add that FeatureSet to the map as a draw-element and even (answer to my second question below) give it a basic popup:

For the popup I first need access to a feature (also there is only one in the Set):

My_feature = My_fset[0]

Now I can add it to the map and define the popup in one go

MyMap.draw(My_fset,{"title":"Popup-Title" , 'content': str(My_feature.attributes['field_a'])+" "+str(My_feature.attributes['field_b'])+': '+str(My_feature.attributes['field_c'])})

Hope this is helpful to anyone else - and still if there is an answer to my initial question - let me know :)