using javascript api 3.10
I am using a popup in a sidepanel. When I click "next" (using the sample integrated in my application) it calls
map.infoWindow.selectNext(); onResultSummaryItemClick(map.infoWindow.selectedIndex);
which then calls
function onResultSummaryItemClick(idx) { // alert(idx); map.infoWindow.select(idx); // alert("index:"+map.infoWindow.selectedIndex); var extent = map.infoWindow.getSelectedFeature().geometry.getExtent(); if (!extent) { // alert(map.infoWindow.getSelectedFeature()+":"+map.infoWindow.getSelectedFeature().geometry); map.centerAndZoom(map.infoWindow.getSelectedFeature().geometry, 18); } else { map.setExtent(extent, true); }
However the selected feature highlight symbol is ending up first in the list, instead of last, so it is drawing UNDER the feature, and therefore isnt appearing highlighted. If i click the feature, the highlight moves to the bottom of the list, and draws correctly.
PATHS after hitting next
PATHS after clicking to select
any ideas? Kelly Hutchins Derek Swingley Jonathan Uihlein
Solved! Go to Solution.
Jeff, my guess is that the creation of the selection graphic is probably not working because the location is not on the screen; you'll have to select it again after you've navigated to the graphic.
Can you try moving the selected graphic to the front. You can do this using
var graphic = popup.getSelectedFeature();
graphic.getShape().moveToFront();
map.infoWindow.select(idx);
var extent = map.infoWindow.getSelectedFeature().geometry.getExtent();
console.log(extent);
var graphic = map.infoWindow.getSelectedFeature();
results in good extent, so map.infoWindow.getSelectedFeature() is fine, but then
Object { type="extent", xmin=-9191676.043059396, ymin=3183521.7840280095, more...}
TypeError: graphic.getShape(...) is null
graphic.getShape().moveToFront();
So it is selecting, it can get the selectedfeature to get an extent (its a polygon) but getShape is returning null
)
Do you have a code sample that shows the problem you can post?
Unfortunately I dont, its in a rather complicated app.
When i console.dir(graphic) prior to trying getShape (also tried getShapes) I get a valid graphic. But even in firebug commandline if I call $p.getShape() it returns null
Jeff, this typically happens when the graphic is not currently loaded into the display. You should first navigate to the appropriate location and then access the shape. For point data you might have to use some other way of navigating to the location of the graphic, but the logic is the same.
map.infoWindow.select(idx);
var selectedFeature = map.infoWindow.getSelectedFeature();
map.setExtent(selectedFeature.geometry.getExtent()).then(lang.hitch(this,function(){
selectedFeature.getShape().moveToFront();
});
still no go
I tried
popup.select(idx);
var extent = popup.getSelectedFeature().geometry.getExtent();
if (!extent) {
map.centerAndZoom(popup.getSelectedFeature().geometry, 18).then(lang.hitch(this,function(){
popup.getSelectedFeature().getShape().moveToFront();
})) ;
} else {
map.setExtent(extent, true).then(lang.hitch(this,function(){
popup.getSelectedFeature().getShape().moveToFront();
}));
}
But it just wont highlight. If the feature is on the screen when i select it from the list, it works.
If it is off the screen, it does not. Even though I am moving to it prior to selecting it.
The if(!extent) above is to handle point data
actually, i dont think this is right. This is moving the selectedfeature to the front, which it is now doing. However it is not moving the HIGHLIGHT graphic, which is what I need.
When i run this from the command line
popup.getSelectedFeature().getShape().moveToFront()
I see the graphic being moved, but its the feature, not the highlight.
Jeff, my guess is that the creation of the selection graphic is probably not working because the location is not on the screen; you'll have to select it again after you've navigated to the graphic.
Baffling as to why I have to do this, but here is the working code. Thanks Kelly and John
popup.select(idx);
var extent = popup.getSelectedFeature().geometry.getExtent();
if (!extent) {
map.centerAndZoom(popup.getSelectedFeature().geometry,18).then(lang.hitch(this,function(){
popup.select(popup.selectedIndex);
})) ;
} else {
map.setExtent(extent, true).then(lang.hitch(this,function(){
popup.select(popup.selectedIndex);
}));
}