POST
|
Hi, I am using ESRI JS API version 4.12. I'm calling require for the following classes. require(["esri/Map", "esri/Color", "esri/views/MapView", "esri/geometry/Point", "esri/widgets/Search", "esri/Graphic", "esri/symbols/PictureMarkerSymbol", "esri/geometry/Circle", "esri/geometry/support/jsonUtils", "esri/symbols/SimpleLineSymbol", "esri/layers/GraphicsLayer", "esri/widgets/Popup", "esri/tasks/Locator", "esri/core/watchUtils", "esri/geometry/Extent", "esri/geometry/geometryEngine", "esri/symbols/SimpleFillSymbol", "esri/Basemap"], funtion(deff) { //Do something resolve(); }); I have registered for require error as follows require.on('error', function (error) { reject(); }); Once require is called it takes few seconds to rersolve. In that time gap the device lost connection, and I get the registered error callback. Once the network is back I'm retrying the above procedure again by calling require with the array of classes. But this time it doesn't resolve at all, i.e I dont get a success or error callback. Is there any way around this behaviour?
... View more
09-17-2019
01:49 AM
|
0
|
0
|
304
|
POST
|
Robert, The end user doesn't need to go through any login screen. Login has to happen in background with one enterprise licence. But we figured it out. So here is code below if anyone has the same question. authenticateAPI: function () {
var me = this;
return new Promise(function (resolve, reject) {
try {
require(["esri/request", "esri/identity/IdentityManager"], function (esriRequest, identityManager) {
var serverAdr = 'https://www.arcgis.com/sharing/rest';
var requestURL = serverAdr + '/oauth2/token?client_id=' + me.client_id + '&client_secret=' + me.client_secret + '&grant_type=client_credentials';
esriRequest(requestURL, {
responseType: "json"
}).then(function (responce) {
identityManager.registerToken({
token: responce.data.access_token,
expires: responce.data.expires_in,
server: serverAdr
});
identityManager.checkSignInStatus('https://www.arcgis.com/sharing').then(function () {
return resolve();
}).catch(function (error) {
return reject();
});
}).catch(function (error) {
return reject();
});
});
} catch (exception) {
return reject();
}
});
} Thanks
... View more
03-13-2019
07:58 AM
|
0
|
0
|
607
|
POST
|
Hi, We have a hybrid mobile app, UI running on web view. We're migrating the app from google maps for JS to ArcGis 4.10 for JS. Google maps signs in with a developer token. Is there an equivalent in ArcGis? Named user login is not viable for us. We want all the user be using a corporate licence. We have created a developer account and registered the app as a web application, and we got the Client ID, Client Secret, Temporary Token. But we have no clue what to do with them. We have a server setup, that can get us any access token or user id before initialising the ArcGis API. Any sample code for the same will be helpful.
... View more
03-12-2019
08:42 PM
|
1
|
2
|
798
|
POST
|
Hi Robert, The solution worked. So the code now looks as follows. setBounds: function (mapsterGeoJson, singularity) {
var me = this;
me.getVendorView().whenLayerView(mapsterGeoJson.getVendorGeoJSON()).then(function () {
var blackhole = me.createPointExtent(singularity.getValue()); //Create extent at the center
var maxDist = 0, tempDist = 0;
mapsterGeoJson.getVendorGeoJSON().graphics.forEach(function (graphics) {
tempDist = me.mapObj.apiInterface.geometry.geometryEngine.distance(singularity.getValue(),
graphics.geometry);
if (tempDist > maxDist) {
maxDist = tempDist;
}
}); //Find the farthest distance from center
/*Expand the extent to the farthest geometry. And acounting for device aspect ratio.*/
blackhole.expand((maxDist + (maxDist * 1.5)) / blackhole.width);
me.getVendorView().goTo(blackhole);
});
return this;
},
createPointExtent: function (pointGeometry) {
var clickOffset = 6;
var centerPoint = pointGeometry.clone();
var mapWidth = this.getVendorView().extent.width;
var pixelWidth = mapWidth / this.getVendorView().width;
var tolerance = clickOffset * pixelWidth;
var queryExtent = new this.mapObj.apiInterface.geometry.Extent({
xmin: 1,
ymin: 1,
xmax: tolerance,
ymax: tolerance,
spatialReference: pointGeometry.spatialReference
});
return queryExtent.centerAt(centerPoint);
}, Thank you for the help.
... View more
02-11-2019
12:56 AM
|
0
|
1
|
1449
|
POST
|
Robert, Tried it, but doesn't work. setBounds: function (mapsterGeoJson, boundCen) {
var me = this;
var tempExtnt = null;
var resExtnt = this.createPointExtent(boundCen.getValue());
mapsterGeoJson.getVendorGeoJSON().graphics.forEach(function (graphics) {
tempExtnt = me.createPointExtent(graphics.geometry);
if (!resExtnt.contains(tempExtnt)) {
resExtnt.union(tempExtnt);
}
});
var clonedExtent = resExtnt.clone();
resExtnt.centerAt(boundCen.getValue());
resExtnt.union(clonedExtent);
me.getVendorView().whenLayerView(mapsterGeoJson.getVendorGeoJSON()).then(
function () {
me.getVendorView().goTo(resExtnt);
});
return this;
}, Also couldn't use extent.expand() as it requires a factor to multiply and I have to test all the points after expand till all the points fit. And also the point extents have zero height and width so expand will not modify the extent at all.
... View more
02-10-2019
08:30 AM
|
0
|
3
|
1449
|
POST
|
Hi, I'm trying to derive an extent out of a list of point geometries, so that all the geometries fit into the extent, keeping fixed to a provided centre. The problem I'm having with extent.union() is it, doesn't keep the extent centre fixed. And doing extent.centerAt() post all the union()s does not fit all the points. And extent.expand() does not take a point. Is there a similar solution as google.maps.LatLngBounds.extend(Point) in ARCGis to extend the extent to a given point keeping the centre fixed. fitBounds: function (mapsterGeoJson, boundCen) {
var me = this;
var tempExtnt = null;
var resExtnt = this.createPointExtent(boundCen.getValue());
mapsterGeoJson.getVendorGeoJSON().graphics.forEach(function (graphics) {
tempExtnt = me.createPointExtent(graphics.geometry);
if (!resExtnt.contains(tempExtnt)) {
resExtnt.union(tempExtnt);
}
});
resExtnt.centerAt(boundCen.getValue());
me.getVendorView().whenLayerView(mapsterGeoJson.getVendorGeoJSON()).then(
function () {
me.getVendorView().goTo(resExtnt);
});
return this;
},
createPointExtent: function (pointGeometry) {
return new this.mapObj.apiInterface.geometry.Extent({
xmin: pointGeometry.longitude,
xmax: pointGeometry.longitude,
ymin: pointGeometry.latitude,
ymax: pointGeometry.latitude
});
},
... View more
02-08-2019
08:01 AM
|
0
|
5
|
1680
|
Title | Kudos | Posted |
---|---|---|
1 | 03-12-2019 08:42 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|