function zoomToLocation(location) {
var pt = new Point(location.coords.longitude, location.coords.latitude, new SpatialReference({
wkid : 4236
}));
var outSR = new SpatialReference({
wkid : 27700
});
var PrjParams = new ProjectParameters();
PrjParams.geometries = [pt];
PrjParams.outSR = outSR;
var datumtrans = 1314;
PrjParams.transformation = datumtrans;
geometryService.project(PrjParams, function(projectedPoints) {
console.log('Conversion completed. Datum Transformation: ' + datumtrans + '.');
pt = projectedPoints[0];
map.centerAndZoom(pt, 8);
});
} function zoomToLocation(location) {
console.debug(location);
var pt = new Point(location.coords.longitude, location.coords.latitude, new SpatialReference({
wkid : 4236
}));
//alert("input x = " + location.coords.longitude + " , y = " + location.coords.latitude);
var outSR = new SpatialReference({
wkid : 27700
});
PrjParams = esriRequest.setRequestPreCallback(setTransformationForward);
alert("prjParams datumtrans = " + PrjParams.transformation);
/*geometryService.project(PrjParams, function(projectedPoints) {
console.log('Conversion completed. Datum Transformation: ' + PrjParams.transformationForward + '.');
pt = projectedPoints[0];
map.centerAndZoom(pt, 8);
});*/
}
function setTransformationForward() {
alert("got here");
var PrjParams = new ProjectParameters();
PrjParams.geometries = [pt];
PrjParams.outSR = outSR;
var datumtrans = 1314;
PrjParams.transformation = datumtrans;
PrjParams.transformationForward = false;
return PrjParams;
}
//we call this method once when the application loads so that it will execute afterwards when AJAX requests are fired.
esriRequest.setRequestPreCallback(addTransformationForward);
...
var params = new ProjectParameters();
params.geometries = [point];
...
//setting this parameter is not working (because of NIM090102)
params.transformationForward = false;
gsvc.project(params, function(projectedPoints) {
...
});
function addTransformationForward(ioArgs) {
//lets add the parameter when we catch an AJAX request aimed at our geometry service
if (ioArgs.url == "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/project")
//add the request parameter manually
ioArgs.content = ioArgs.content || {};
ioArgs.content.transformForward = false;
// don't forget to return ioArgs.
return ioArgs;
}
Many thanks for that fiddle - I've just hit a similar issue (user collects in google maps, want to display in our 27700 maps) and a slightly modified version of your code works a treat.