POST
|
Here's my exact use:
define([
"dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dojo/text!./templates/PointPickerWidget.html",
"dojo/_base/event",
"utils/menus",
"dojo/query",
"dojo/dom-construct",
"dojo/topic",
"dojo/on",
"esri/geometry/Point",
"esri/geometry/screenUtils",
"esri/geometry/webMercatorUtils",
"dojo/domReady!"
],
function(declare,
_WidgetBase,
_TemplatedMixin,
template,
Event,
menus,
query,
domConstruct,
topic,
on,
Point,
screenUtils,
webMercatorUtils) {
return declare("PointPickerWidget",[_WidgetBase, _TemplatedMixin], {
templateString: template,
widgetsInTemplate: true,
lat:0,
lng:0,
accuracy:'Obtaining GPS Location...',
tryCount:0,
constructor: function() {
},
postMixInProperties: function() {
},
getAccuracy: function() {
var self = this;
var updatedAccuracy;
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(loc) {
if(loc.coords.accuracy >= 30) {
updatedAccuracy = domConstruct.toDom('GPS Accuracy: ' + loc.coords.accuracy);
domConstruct.place(updatedAccuracy, 'location-accuracy', 'only');
} else {
if(self.tryCount < 3) {
self.getAccuracy();
self.tryCount += 1;
} else {
updatedAccuracy = domConstruct.toDom('Unable to obtain GPS location. Please select a point instead.');
domConstruct.place(updatedAccuracy, 'location-accuracy', 'only');
}
}
});
}
},
postCreate: function() {
domConstruct.place(this.domNode, "point-picker", "only");
this.getAccuracy();
},
getCurrentLocation: function() {
if( navigator.geolocation ) {
navigator.geolocation.getCurrentPosition(function(location) {
var point = new Point(location.coords.longitude, location.coords.latitude);
map.centerAndZoom(point, 12);
var locationInfo = {
coords:location.coords,
point: point
};
topic.publish('location-picked', locationInfo);
});
} else {
alert("Geolocation not supported!");
}
menus.closePointPicker();
},
pickLocation: function() {
menus.closePointPicker();
menus.showTapAndHoldDialog();
map.disableDoubleClickZoom();
var mapDiv = document.getElementById('map');
var hammertime = Hammer(mapDiv);
hammertime.on("hold", function (evt) {
// convert screen coords to map coords
var x, y, point, mapPoint;
x = evt.gesture.center.pageX;
y = evt.gesture.center.pageY;
point = new Point(x, y);
mapPoint = screenUtils.toMapPoint(
map.extent,
map.width,
map.height,
point
);
var latLng = webMercatorUtils.xyToLngLat(mapPoint.x, mapPoint.y);
var location = {};
coords = {
latitude: latLng[1],
longitude: latLng[0],
accuracy:null,
heading:null
};
var locationInfo = {
coords:coords,
point: mapPoint
};
hammertime.off("hold");
topic.publish('location-picked', locationInfo);
menus.hideTapAndHoldDialog();
});
}
}
);
});
... View more
06-05-2014
01:17 PM
|
0
|
0
|
505
|
POST
|
Ever find a solution for dbltap on touch? I need this as well. I ended up using a press and hold event from Hammer.js. I would have used the dojo/touch events, but their tap-hold event doesn't support returning screen coordinates.
... View more
05-15-2014
10:22 AM
|
0
|
0
|
505
|
POST
|
The service has been regenerated, nothing exists there yet. The ESRI Date Type is the only date/time type that I can see. Now, from all the responses here, a normal unix timestamp is what ArcGIS Online services expect as a param. (The number of seconds from Jan 1, 1970) Is this correct?
... View more
05-11-2014
02:07 PM
|
0
|
0
|
1262
|
POST
|
I guess I must be using the wrong type of date field or something. That doesn't work for me. Here's my service definition: https://services1.arcgis.com/BqQ60RORKMjmx3jf/ArcGIS/rest/services/Photos_Template/FeatureServer/0 (I don't think token is required) -Jim
... View more
05-08-2014
01:24 PM
|
0
|
0
|
1262
|
POST
|
Can someone give me an example of how I would query a featurelayer by date? I have a field in my featureservice named 'time'. The field type is: type: esriFieldTypeDate Is this documented anywhere what that field type expects? I've sent all kinds of different date formats including: mm/dd/yyyy yyyy-mm-dd yyyy-mm-dd HH:MM:SS unix_time_stamp (1399336752182) I'm sure someone out there has queried features before or after a particular date... I'd just like to see an example as I can't find any API docs that show how this should be done.
... View more
05-05-2014
04:40 PM
|
0
|
6
|
5817
|
POST
|
Ok, doing that (turning it into a standard Unix timestamp, gives me this as a query param: where:time > 1398729600000 That looks correct, but I'm still getting the same error. The entire method looks like this:
buildQuery: function() {
var query = [];
var name = this.username.value;
var startDate = this.startDate.value;
var endDate = this.endDate.value;
if(name) {
query.push("username LIKE '%"+name+"%'");
}
if(startDate) {
query.push("time > "+new Date(startDate).valueOf());
}
if(endDate) {
query.push("time < "+new Date(endDate).valueOf());
}
if(query.length > 1) {
return query.join(' AND ');
} else {
return query.join('');
}
},
The feature layer definition has list of fields is as follows: Fields: FID (type: esriFieldTypeInteger, alias: FID, SQL Type: sqlTypeInteger, nullable: false, editable: false) username (type: esriFieldTypeString, alias: username, SQL Type: sqlTypeNVarchar, length: 254, nullable: true, editable: true) lat (type: esriFieldTypeDouble, alias: lat, SQL Type: sqlTypeFloat, nullable: true, editable: true) lng (type: esriFieldTypeDouble, alias: lng, SQL Type: sqlTypeFloat, nullable: true, editable: true) accuracy (type: esriFieldTypeDouble, alias: accuracy, SQL Type: sqlTypeFloat, nullable: true, editable: true) heading (type: esriFieldTypeDouble, alias: heading, SQL Type: sqlTypeFloat, nullable: true, editable: true) time (type: esriFieldTypeDate, alias: time, SQL Type: sqlTypeTimestamp2, length: 8, nullable: true, editable: true) photo (type: esriFieldTypeString, alias: photo, SQL Type: sqlTypeNVarchar, length: 254, nullable: true, editable: true) photothumb (type: esriFieldTypeString, alias: photothumb, SQL Type: sqlTypeNVarchar, length: 254, nullable: true, editable: true)
... View more
04-30-2014
03:25 PM
|
0
|
0
|
249
|
POST
|
My data is just coming from a FeatureLayer. I'm not actually directly querying a database. When using a query (https://developers.arcgis.com/javascript/jsapi/query-amd.html) I just need to return features newer than a particular date that is set by the user.
... View more
04-29-2014
10:11 AM
|
0
|
0
|
249
|
POST
|
Ok, perhaps I'm misunderstanding. I've attempted to prepend 'date' to my queries. They're still misunderstood.
"time < date'"+this.esriDate(endDate)+"'"
Still throws an error. I haven't found any docs telling me what date format ESRI expects.
... View more
04-29-2014
09:07 AM
|
0
|
0
|
721
|
POST
|
Ok, so we're casting it as some sort of date type? Can I cast dates in the original format? (YYYY-MM-DD) or do they need to be in the mm/dd/yyyy format before they're casted? That just changes my query parameters to look like this: f:json where:time > date'2/4/2014' returnGeometry:true spatialRel:esriSpatialRelIntersects outFields:* outSR:102100 It still fails. What is the acceptable way to query features by date? I haven't found any examples.
... View more
04-29-2014
07:39 AM
|
0
|
0
|
721
|
POST
|
Interesting, how do I get that when writing a query? Currently, I'm setting it up like this:
esriDate: function(date) {
var dateArr = date.split('-');
dateArr.push(dateArr.shift());
return dateArr.map(function(el) { return parseInt(el, 10); } ).join('/');
},
buildQuery: function() {
var query = [];
var name = this.username.value;
var startDate = this.startDate.value;
var endDate = this.endDate.value;
if(name) {
query.push("username LIKE '%"+name+"%'");
}
if(startDate) {
query.push("time > '"+this.esriDate(startDate)+"'");
}
if(endDate) {
query.push("time < '"+this.esriDate(endDate)+"'");
}
if(query.length > 1) {
return query.join(' AND ');
} else {
return query.join('');
}
},
submitQuery: function(e) {
e.preventDefault();
var query = new Query();
query.returnGeometry = true;
query.where = this.buildQuery();
this.layer.selectFeatures(query, this.layer.SELECTION_NEW, function(data) {
console.log(data);
// var extent = graphicsUtils.graphicsExtent(data);
// map.setExtent(extent, true);
});
menus.closeFeatureQuery();
this.destroy();
}
The query looks "mostly" SQLish. How do I specify that it's a date?
... View more
04-29-2014
07:33 AM
|
0
|
0
|
721
|
POST
|
Ok, sadly, that still is giving me an error. My query params are as follows: f:json where:time > '2/4/2014' returnGeometry:true spatialRel:esriSpatialRelIntersects outFields:* outSR:102100 If I omit any dates from my search and search on things like 'username'. (" username LIKE '%"+username+"%'") My searches work just fine. It's only the dates that fail.
... View more
04-29-2014
07:09 AM
|
0
|
0
|
721
|
POST
|
Thanks! Ok, so if slashed dates are the required format, I could do this:
var date = '2014-04-29'.split('-');
var esriDate = parseInt(date[1], 10) + '/' + parseInt(date[2], 10) + '/' + date[0];
... View more
04-29-2014
06:35 AM
|
0
|
0
|
721
|
POST
|
I have a featurelayer with a field with "type: esriFieldTypeDate". I have a form on a page using the standard HTML5 date input type. (it uses the browser's built in datepicker) The format that this returns is in this format: '2014-04-29'. When I try to send this in a query, I get an error: "Unable to perform query. Please check your parameters." What type of date format should I send in a query/querytask to be able to select dates before/after a chosen date? I've tried using a javascript new Date(). I've tried sending it as 'YYYY-MM-DD', but nothing else.
... View more
04-29-2014
05:42 AM
|
0
|
13
|
1818
|
POST
|
Oh wow... the docs all have it as "esri/tasks/Query". Where did you get the heads-up that it should be lowercase?
... View more
03-27-2014
04:44 PM
|
0
|
0
|
271
|
POST
|
I'm getting 404ed on this file: http://js.arcgis.com/3.7/js/esri/tasks/Query.js Anyone else seeing the same?
... View more
03-27-2014
04:13 PM
|
0
|
3
|
623
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|