So i have a data source beeing loaded in a symbolLayer in Azure Maps, all its working fine. But i cant find a way to show to my user what feature is beeing clicked on the map. Here is my code. I cant get the information about the feature is beeing clicked, but i cant find the way to change the style of the feature. Anything that can show the user that he clicked that feature its ok for me. Even a dot on top of the feature. If you guys know what is doing my popup to appear not on top of my feature but overlapping him i would aprecciate too.
Popup popup = new Popup();
map.popups.add(popup);
//Add a click event to the layer.
map.events.add((OnFeatureClick)(feature) -> {
//Get the first feature and it's properties.
Feature f = feature.get(0);
JsonObject props = f.properties();
//Retrieve the custom layout for the popup.
View customView = LayoutInflater.from(this).inflate(R.layout.popup_text, null);
//Display the name and entity type information of the feature into the text view of the popup layout.
TextView tv = customView.findViewById(R.id.message);
tv.setText(f.getStringProperty("Name") + "\n" +
f.getStringProperty("Pvm"));
//Get the position of the clicked feature.
Position pos = MapMath.getPosition((Point)f.geometry());
//Set the options on the popup.
popup.setOptions(
//Set the popups position.
position(pos),
//Set the anchor point of the popup content.
anchor(AnchorType.BOTTOM),
//Set the content of the popup.
content(customView),
//add a button to close popup
closeButton(false)
);
//Open the popup.
popup.open();
map.events.add((OnClick) (lat, lon) -> {
//Map clicked.
popup.close(customView);
popup.setOptions(iconImage("ic_square_w"));
//Return true indicating if event should be consumed and not passed further to other listeners registered afterwards, false otherwise.
return true;
});
//Return a boolean indicating if event should be consumed or continue to bubble up.
return true;
});
The easiest way to add a visual highlight that shape has been selected, is to use a second datasource, and add a feature to it and render it with a layer differently.