this is my code. i clicked symbol and show infoTemplate . i want call function showResults(featureSet) show infoTemplate
function showResults(featureSet) {
//remove all graphics on the maps graphics layer
myMap.graphics.clear();
var resultFeatures = featureSet.features;
//Loop through each feature returned
for (var i = 0, il = resultFeatures.length; i < il; i++) {
//Get the current feature from the featureSet.
//Feature is a graphic
var attr = resultFeatures.attributes;
var title = attr.TEN;
var content = "Field ID : " + attr.OBJECTID
+ "<br />Tên: " + attr.TEN
+ "<br />Địa chỉ : " + attr.TEN
//initialize InfoTemplate
infoTemplate = new InfoTemplate("Kết quả tìm kiếm:", content);
// myMap.infoWindow.setTitle(title);
// myMap.infoWindow.setContent(content);
// myMap.infoWindow.show(resultFeatures[0].geometry);
var graphic = resultFeatures;
graphic.setSymbol(symbol1);
//Set the infoTemplate.
graphic.setInfoTemplate(infoTemplate);
// //Add graphic to the map graphics layer.
// myMap.graphics.add(graphic);
myMap.graphics.add(graphic);
//
myMap.centerAndZoom(resultFeatures[0].geometry, 7);
}
}
Solved! Go to Solution.
Hi Ia,
If your geometry is expected to points, add below lines after your myMap.centerAndZoom(resultFeatures[0].geometry, 7);
myMap.infoWindow.setFeatures([resultFeatures[0]]); // Get first feature and add it into an array.
myMap.infoWindow.show(resultFeatures[0].geometry); // Show info window at the location of your first feature.
This should do the trick.
Can you provide a Place or Space where you would like this redirected. Also, providing some tags for your post in the tags section would facilitate getting an answer
my problem is how to show symbol and infotemplate that no click symbol.
Hi Ia,
If your geometry is expected to points, add below lines after your myMap.centerAndZoom(resultFeatures[0].geometry, 7);
myMap.infoWindow.setFeatures([resultFeatures[0]]); // Get first feature and add it into an array.
myMap.infoWindow.show(resultFeatures[0].geometry); // Show info window at the location of your first feature.
This should do the trick.
Riyas, it works exactly as I expected.I hope these help you later. thanks Riyas...