Hi
A default popup appear when i click on vertice of polygon. As i m also using markers with popup in my app, but they also appear on my vertices with default body.
The line in bold shows my popup, but it should not work for polygon vertices.
// This function is called when a user clicks on the view.
function setUpGraphicClickHandler() {
view.on("click", function(event) {
view.hitTest(event).then(function(response) {
var results = response.results;
if(results.length === 0){
sketchViewModel.complete();
markersketchViewModel.complete();
}
// Check if the new development graphic and temp graphics with attribute named newDevelopment was clicked and pass
// the graphic to sketchViewModel.update() with reshape tool.
results.forEach(function(result) {
if (
result.graphic.layer === sketchViewModel.layer &&
result.graphic.attributes &&
result.graphic.attributes.newDevelopment
) {
sketchViewModel.update([result.graphic], { tool: "reshape" });
} else if(
result.graphic.layer === markersketchViewModel.layer &&
result.graphic.attributes &&
result.graphic.attributes.newDevelopment){
markersketchViewModel.update([result.graphic], { tool: "reshape" });
}
else if(sketchViewModel.state !== 'active'){
sketchViewModel.cancel();
// view.popup.open({features: [result.graphic], location: result.graphic.geometry});
} else if(markersketchViewModel!== 'active' ){
markersketchViewModel.cancel();
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
});
});
});
}//End setUpGraphicClickHandler
Solved! Go to Solution.
Well your code blocked my markers also, so i did some minor editing, and now it works fine.
else if(sketchViewModel.state !== 'active'){
sketchViewModel.cancel();
//view.popup.open({features: [result.graphic], location: result.graphic.geometry});
} else if(markersketchViewModel.state!== 'active'){
markersketchViewModel.cancel();
if( result.graphic.attributes &&
result.graphic.attributes.newDevelopment){
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
}
Rajni,
The popup is appearing because you are telling it to in your code.
} else if(markersketchViewModel!== 'active' ){
markersketchViewModel.cancel();
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
You have markersketchViewModel!== 'active' . Well markersketchViewModel is never going to equal a string of active... Maybe you mean markersketchViewModel.state !== 'active'.
Ok, but the the problem still persists, default popup still appears on vertices
Your next issue is that you are not checking the state of your default sketchviewmodel.
Sir
I am checking its state here
else if(sketchViewModel.state !== 'active'){
sketchViewModel.cancel();
// view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
Rajni,
Hmm. is that code from a different area of your code?
I was envisioning something like this:
} else if(markersketchViewModel.state !== 'active' && sketchViewModel.state !== 'active'){
markersketchViewModel.cancel();
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
No sir
I have sketchviewmodel for property boundaries and markersketchviewmodel to create marker with polygons. So i have 2 sketchview models iin my code,
but markersketchview model default popup appear for vertices of sketchviewmodel.
Now i m confused!!!
function setUpGraphicClickHandler() {
view.on("click", function(event) {
view.hitTest(event).then(function(response) {
var results = response.results;
if(results.length === 0){
sketchViewModel.complete();
markersketchViewModel.complete();
}
// Check if the new development graphic and temp graphics with attribute named newDevelopment was clicked and pass
// the graphic to sketchViewModel.update() with reshape tool.
results.forEach(function(result) {
if (
result.graphic.layer === sketchViewModel.layer &&
result.graphic.attributes &&
result.graphic.attributes.newDevelopment
) {
sketchViewModel.update([result.graphic], { tool: "reshape" });
} else if(
result.graphic.layer === markersketchViewModel.layer &&
result.graphic.attributes &&
result.graphic.attributes.newDevelopment){
markersketchViewModel.update([result.graphic], { tool: "reshape" });
}
else if(sketchViewModel.state !== 'active'){
sketchViewModel.cancel();
//view.popup.open({features: [result.graphic], location: result.graphic.geometry});
} else if(markersketchViewModel.state!== 'active'){
markersketchViewModel.cancel();
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
});
});
});
}//End setUpGraphicClickHandler
Well you have me confused too. Why in the world do you have two different sketchview models? You do not not need a different on just to draw points/markers, that just complicates your code...
Well markersketchviewmodel draw boundaries also with different color and attributes you can say zones on the person properties to separate them like areas in property with low signal areas of property or high signal, ie the idea, so they must be used and act differently alot.
So to separate basic property polygon from their numerous areas of it
and their graphic layer iss also differnt. to make layers working more comfortable for zones and basic properties