|
POST
|
I am trying to get the results from a FeatureLayer when the user clicks on the map. My geometry is an map.MapPoint that i pass to the following function. I tried to make a rectangle for making a polygon to add more range to the results but for some reasonim getting an error performing the query function factigis_findDireccion(geometry,callback){
var rectangulo = new esri.geometry.Polygon;
rectangulo.addRing(crearRectangulo(geometry,1));
console.log("my point",rectangulo);
var qTaskInterruptions = new esri.tasks.QueryTask(layers.read_direcciones());
var qInterruptions = new esri.tasks.Query();
qInterruptions.returnGeometry = true;
qInterruptions.outFields=["id_direccion","nombre_calle","numero"];
qInterruptions.geometry = rectangulo ;
qInterruptions.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
qTaskInterruptions.execute(qInterruptions, (featureSet)=>{
console.log("Find",featureSet);
callback(featureSet.features);
}, (Errorq)=>{
console.log(Errorq,"Error doing interruptions nis by extent");
return 0;
});
}
function crearRectangulo(mapPoint,delta){
var arrayOfPoints = new Array();
arrayOfPoints[0] = new esri.geometry.Point(mapPoint.x-delta,mapPoint.y-delta,mapPoint.spatialReference);
arrayOfPoints[1] = new esri.geometry.Point(mapPoint.x-delta,mapPoint.y+delta,mapPoint.spatialReference);
arrayOfPoints[2] = new esri.geometry.Point(mapPoint.x+delta,mapPoint.y+delta,mapPoint.spatialReference);
arrayOfPoints[3] = new esri.geometry.Point(mapPoint.x+delta,mapPoint.y-delta,mapPoint.spatialReference);
arrayOfPoints[4] = new esri.geometry.Point(mapPoint.x-delta,mapPoint.y-delta,mapPoint.spatialReference);
return arrayOfPoints;
} What im missing? thanks for ur help
... View more
06-14-2016
12:24 PM
|
0
|
1
|
2665
|
|
POST
|
Oh i did it already adding an state for the map_click_handle: onToggleButtonClick(e){
var map = this.props.themap;
var map_click_handle;
if (this.state.toggleCliente =='OFF'){
this.setState({toggleCliente: 'ON'});
$('.factigis_btnSelectCliente').css('color',"crimson");
map_click_handle = dojo.connect(map, 'onClick', (g)=>{
console.log("My click", g);
});
this.setState({btnCliente: map_click_handle});
}else{
this.setState({toggleCliente: 'OFF'});
$('.factigis_btnSelectCliente').css('color',"black");
dojo.disconnect(this.state.btnCliente);
}
} Thanks anyways
... View more
06-13-2016
07:33 AM
|
0
|
0
|
898
|
|
POST
|
Hello, I have a toggle button that i need to use for handling the map click. I have the following code but i cannot disable the map click for some reason. I searched already in the working with events page and i dont know what im missing. My code is: onToggleButtonClick(e){
var map = this.props.themap;
var map_click_handle;
//enable the map click and get the geometry point
if (this.state.toggleCliente =='OFF'){
this.setState({toggleCliente: 'ON'});
$('.factigis_btnSelectCliente').css('color',"crimson");
map_click_handle = dojo.connect(map, 'onClick', (g)=>{
console.log("My click", g);
});
//disable the map click to not get the geometry point.
}else{
this.setState({toggleCliente: 'OFF'});
$('.factigis_btnSelectCliente').css('color',"black");
dojo.disconnect(map_click_handle);
}
}
... View more
06-13-2016
07:29 AM
|
0
|
1
|
1390
|
|
POST
|
Maybe if u show ur code in jsfiddle we can see what is going wrong. But remember that u need to do the query every time when u select a new item (or when u change ur map extent), so u will have to make a listener that allows to perform the query every time u make a selection or change the map extent. For example, in my case i had to make a table that refreshes the result every time i change the map extent, so i applied a listener on the map, like: map.on('extent-change', ()=>{ getInfoByExtent((map.extent), (myresultcallback)=>{do something with the callback that i got } }); My query is: function getInfoByExtent(extent, callback){ var qTask = new esri.tasks.QueryTask(mylayer); var q= new esri.tasks.Query(); q.where = "1=1"; q.returnGeometry = true; q.outFields=["*"]; q.geometry = extent; q.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS; qTask.execute(q, (featureSet)=>{ callback(featureSet.features); }, (Errorq)=>{ console.log(Errorq,"Error doing query by extent"); return 0; }); }
... View more
04-28-2016
08:19 AM
|
0
|
2
|
4412
|
|
POST
|
The other option is: In ur sql database make a view with the query that u show me. Then u go to ur arcgis and publish the view with a where option that u need, in this case u will need a where clausule to get the last record. Cuz arcgis cannot make complex queries, i do this when i need more complex data. (so the view works as a table where i can access that data)
... View more
04-28-2016
08:05 AM
|
2
|
0
|
3668
|
|
POST
|
Why u just dont show it at startup (hide it with css) and then when u make a selection u show the table with the selected data making a query with geometry? And if the user click on something else that is not the map or the table itself u hide it again?
... View more
04-28-2016
07:59 AM
|
0
|
4
|
4412
|
|
POST
|
Make a service with the sql query that u need and publish it (as data table) and then u can access the data using the normal query and querytask.
... View more
04-28-2016
07:54 AM
|
0
|
1
|
3668
|
|
POST
|
Ok, it was that, Thanks for all ur help! I finished my quest doing this. For controlling the token expiration i used an event for the dynamic service that i was accessing. Example: my layer has a refreshInterval =1; So, in every minute it will be refreshed, but what happen if the token that allows me to update it is already expired? To solve that i used: interrClienteSED.on('update-end', (obj)=>{
if(obj.error){
console.log("Redirecting to login page, token for this session is ended...");
window.location.href = "index.html";
}
}); So that will return an object that contains error if the update cannot be done or info if its still ok and it will be checking it every minute. In my case i want to redirecto to the login page (index). In the case if i go directly to my secondary page (the page after the login), I have to see if the token is still valid, then i just use my ajax call: function tokenValidator(){
var t = localStorage.getItem('token');
const exampleUrl = "http://myservice/arcgis/rest/services/mylayer/MapServer";
const datas = {
token: t,
f: "json"
};
console.log("in token validator");
$.ajax({
method: "POST",
url: exampleUrl,
dataType: 'html',
data: datas
})
.done(isDone => {
if (isDone.indexOf('Invalid Token') >= 0){
console.log("redirect to login page from token validator...");
window.location.href = "index.html";
}else{
console.log("everything is ok! u can continue doing what u are doing.");
}
})
.fail(error => {
console.log("token validator failure", error);
});
} I hope this helps to someone that has the same issue . Thanks!
... View more
04-26-2016
11:48 AM
|
1
|
0
|
4411
|
|
POST
|
Sorry it was 200, not 400. For example i have the following: function tokenValidator(){
var t = localStorage.getItem('token');
const exampleUrl = "http://myserver/arcgis/rest/services/mylayer/mysub/MapServer";
const datas = {
token: t
};
$.ajax({
method: "POST",
url: exampleUrl,
dataType: 'json',
data: datas
})
.done(isDone => {
console.log("token validator sucess", isDone);
//if my token is still valid i keep the main app.
})
.fail(error => {
console.log("token validator failure", error);
//if i get the token is not valid i have to redirect my page to the login.
});
} In the console i have this: token validator failure object: status: 200 statusText: ok And i got the url where i want to access. But sometimes i got the login arcgis website.
... View more
04-25-2016
11:16 AM
|
1
|
1
|
4411
|
|
POST
|
Oh thats true. I will try it and put the result here just in case if someone needs it. About the ajax fetching the secured service folder, do u have any example for getting the "error" result? cuz i always get a "400" error.
... View more
04-25-2016
09:58 AM
|
0
|
1
|
4411
|
|
POST
|
try to follow my logic to solve ur issue First u need to do the query to pass the parameters to that function: function templateContent(graphic, infoTemplate){ var attr = graphic.attributes['thumbnails']; if (attr = "NoImage2.jpg"){ var infoContent1 = "<b>BN: </b>"+ bldgContentObject.buildingNumber + "<br><b>Thumbnail: </b>" + "<img>${thumbnails}</img>"; infoTemplate.setContent(infoContent1); }else{ var infoContent2 = "<b>BN: </b>" + bldgContentObject.buildingNumber; infoTemplate.setContent(infoContent2); } }
... View more
04-21-2016
01:27 PM
|
0
|
0
|
2379
|
|
POST
|
Hello, I need to know if theres a way of validate the token once u saved it in localStorage. Right now im creating tokens with a certain duration (lets say 1day) and using them directly on the webservice. So i need to know once u save it in a localStorage var how to validate if the token is already expired or not. I was thinking to do this through ajax but i cannot figure out how to do it. Until now i have something like this, i hope u guys can help me function tokenValidator(t){
const exampleUrl = "http://myserver/arcgis/rest/services/mylayer/sufolder/MapServer";
const datat = {
token: t
};
console.log(t);
$.ajax({
url: exampleUrl,
dataType: 'json',
data: datat
})
.done(isDone => {
console.log(isDone);
console.log("the token is still valid");
})
.fail(error => {
console.log(error);
console.log("token is not valid, redirect to login page");
});
}
... View more
04-21-2016
12:18 PM
|
0
|
6
|
6935
|
|
POST
|
when u capture the pic that u want to upload in ur app u have the following 2 steps: 1st: see the file size. How it has to be less than 1mb before u upload it to the service, u need to see the var myvar.size of the file < than 10000 (in kb). 2nd: if the size is ok, then u have to check if the feature that u wanna add the attachment it has attch already, so u can do that with queryAttachmentInfos. So if the result returns an array with 1 or more results for that feature, u need to delete them or not let the user upload the pic. In the case if u wanna overwrite ur pic, u need to delete all the attachments related to that feature and then upload ur pic. I hope this help.
... View more
04-19-2016
11:51 AM
|
0
|
0
|
1145
|
|
POST
|
I dont understand ur question , but i worked with attachments before. U must specified: Content Type: JPEG, PNG, PDF, etc Size: 470812 (in kb ) I remember in flex i worked with bytearrays to add the files at the server.
... View more
04-14-2016
02:38 PM
|
0
|
2
|
1145
|
|
POST
|
I solved my problem. function saveLogin(user,page,module){
const data = {
f: 'json',
adds: JSON.stringify([{ attributes: { "user": user, "page": page, "module": module }, geometry: {} }])
};
jQuery.ajax({
method: 'POST',
url: myLayers.write_logAccess(),
data: data,
dataType:'json',
success: (success) => {
console.log(success);
},
error: (error) => {
console.log(error);
}
});
}
... View more
04-14-2016
01:52 PM
|
2
|
0
|
3552
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-21-2017 02:09 PM | |
| 1 | 04-10-2015 07:52 AM | |
| 1 | 03-23-2016 02:08 PM | |
| 1 | 02-22-2016 05:01 AM | |
| 1 | 10-09-2018 07:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
05-01-2024
03:05 AM
|