POST
|
Hi, I'm trying to take the geometry of a geocoder search result and use that as the input geometry to query against a feature layer. If the geometry returned by the geocoder search result intersects a polygon in the feature layer, then a popup appears to display some of the attributes of the layer. This works fine for one-off address searches. It also works fine if I search for a new address after finding the first address and the new address is in a different polygon in the feature layer to the previous polygon that was selected in the first address search. However in the scenario where the first search is completed and a second address is searched and that second address intersects the same polygon as was selected by the first search, I'm having some problems. In this scenario the map first starts to recentre on the second address but then quickly zooms back to the location of the first address. In the console the following error messages appear: "exception in animation handler for: onAnimate TypeError: d is undefined .cache["esri/dijit/Popup"]/</e<._onPan()/3.8compact/ (line 543) .cache["dojo/_base/lang"]/</g.hitch/<()/3.8compact/ (line 173) .cache["dojo/aspect"]/</n/</h()/3.8compact/ (line 238) .cache["esri/_coremap"]/</p<._panningHandler()/3.8compact/ (line 828) .cache["dojo/_base/lang"]/</g.hitch/<()/3.8compact/ (line 173) .cache["dojo/aspect"]/</n/</h.around.advice()/3.8compact/ (line 238) .cache["dojo/aspect"]/</n/</h()/3.8compact/ (line 238) .cache["dojo/_base/fx"]/</<._fire()/3.8compact/ (line 44) .cache["dojo/_base/fx"]/</<._cycle()/3.8compact/ (line 48) .cache["dojo/_base/lang"]/</g.hitch/<()/3.8compact/ (line 172) .cache["dojo/aspect"]/</n/</h()/3.8compact/ (line 238) .cache["dojo/_base/lang"]/</g.hitch/<()/3.8compact/ (line 172) Reload the page to get source for: http://js.arcgis.com/3.8compact/" These error messages appear 4 times in a row. Here is my code: function startGeocoder() {
geocoder = new Geocoder({
map : map,
arcgisGeocoder : {
placeholder : "Address search",
sourceCountry : "GBR"
}
}, "search");
geocoder.autoComplete = true;
geocoder.startup();
geocoder.on("select", queryLayer);
}
function queryLayer(evt){
popup.hide();
selectTariffLayer.clearSelection();
var point = evt.result.feature.geometry;
var query = Query();
query.geometry = point;
selectTariffLayer.selectFeatures(query, selectTariffLayer.SELECTION_NEW, function(results){
var charge = results[0].attributes["Charge"];
var price = results[0].attributes["Cost"];
popup.setTitle("Parking tariffs");
popup.setContent(charge + "<br/>" + price);
popup.show(point);
});
} Any suggestions where I'm going wrong? Cheers, Mike
... View more
04-24-2014
07:25 AM
|
0
|
6
|
2526
|
POST
|
Thanks John, that's it working now. That's greatly appreciated. Cheers, Mike
... View more
04-09-2014
07:50 AM
|
0
|
0
|
1670
|
POST
|
Erm, callbacks are not something I've worked with much so I'm struggling a bit. I've tried a few different things but I can't see how I should use the callback to set the parameters, sorry. 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;
}
... View more
04-08-2014
09:44 AM
|
0
|
0
|
1670
|
POST
|
Sorry you've lost me here, how can I use esriRequest.setRequestPreCallback() to set the transformationForward boolean? (it's false I need to set the transformationForward boolean to)
... View more
04-08-2014
08:56 AM
|
0
|
0
|
1670
|
POST
|
Thanks for your reply. Yeah I had been using ArcGIS Server 10.0 without thinking about it. We've also got a server running ArcGIS Server v10.2 and I've put the code into a javascript map on that server and when I put in the datum transformation as 1314 it shifts the results further to the west (they should be getting shifted to the east). In your link http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/project I've just seen the transform forward parameter and notice that when I change it there it changes the values. How do I change this parameter in my code? I've tried playing about with something along the lines of PrjParams.transformationForward = true; or PrjParams.transformationForward = false; but it doesn't change the output value. Cheers, Mike
... View more
04-08-2014
08:34 AM
|
0
|
0
|
1670
|
POST
|
Hi, I'm trying to convert coordinates from WGS84 to British National Grid using the geometry service but when I do this, the points all seem to be a bit out (maybe 100m or so). From reading up on this it seems that the reason is probably I'm not doing a datum transformation to the coordinates. However, I can't find out what value to put in for the datum transformation. The starting coordinates come from the geolocation API so are in WKID 4326, so the starting datum should be WGS1984 I think. The output spatial reference is British National Grid (WKID 27700) so it's datum is OSGB_1936. I've been searching to find out what the value for the datum transformation should be and the closest I've come is EPSG::1314 which is for WGS1984_To_OSGB_1936. I've tried specifying this as the datum transformation value but the output point is in the same location as if I leave this datum transformation parameter blank. Has anyone else come across this? 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);
});
}
... View more
04-08-2014
07:28 AM
|
0
|
11
|
4227
|
POST
|
Thanks Michael. Yesterday I'd misunderstood the instructions for testing this link: http://[yourmachine]/DotNet/proxy.ashx?http://services.arcgisonline.com/ArcGIS/rest/services/?f=pjson and today I can see that this is working. I have another question though - how can I test that the proxy is working in my javascript application? In my javascript application the buffer operation was completing successfully before I put in the proxy reference. If I look in the developer tools at the network requests it says: Request URL:https://edinburghcouncilmaps.info/arcgis/rest/services/Utilities/Geometry/GeometryServer/buffer?f=json&unit=9001&unionResults=false&geodesic=false&geometries=%7B%22geometryType%22%3A%22esriGeometryPoint%22%2C%22geometries%22%3A%5B%7B%22x%22%3A322705.57636948605%2C%22y%22%3A668167.0265007198%2C%22spatialReference%22%3A%7B%22wkid%22%3A27700%7D%7D%5D%7D&inSR=27700&distances=35 Request Method:GET Should the request method not say POST? Cheers
... View more
04-04-2014
02:30 AM
|
0
|
0
|
1182
|
POST
|
Thanks for your replies. I've got one or two more questions. The maps that will perform the buffer have to be accessed via https without any certificate warnings. How can I be sure the proxy is working correctly? I've followed the instructions on github but when I go check the proxy is able to forward request directly in the browser I get a 403 error message saying access is denied: https://edinburghcouncilmaps.info/proxy/proxy.ashx?http://services.arcgisonline.com/ArcGIS/rest/services/?f=pjson Any ideas why this might be? I also don't really understand the bit on github where it gives a javascript example for requests to route.arcgis.com urlUtils.addProxyRule({
urlPrefix: "route.arcgis.com",
proxyUrl: "http://[yourmachine]/proxy/proxy.ashx"
}); When I set-up a proxy on a different server a few months ago the instructions I followed just said to add this line into the javascript: esriConfig.defaults.io.proxyUrl = "/proxy"; Is this enough or do I need to do the addProxyRule? Cheers, Mike
... View more
04-03-2014
09:56 AM
|
0
|
0
|
1182
|
POST
|
Hi, I'm an ArcGIS Server Javascript API application that uses the buffer operation to buffer a point by 35m and finds features within that distance. The javascript API documentation recommends using a proxy page if doing buffer operations but then in the part in the javascript API documentation that explains the proxy page it says ???Common scenarios where you may run into URL length issues are when you use the buffer from a complex polygon as the input to a query task???. If I???m only buffering a point then would that run the risk of running into URL length issues? What is the URL that would be potentially long? And how can I test the length of the URL being created? Cheers, Mike
... View more
04-02-2014
08:56 AM
|
0
|
9
|
1435
|
POST
|
Hi, I'd like to do the same thing. Did you ever get a working solution? Cheers, Mike
... View more
02-11-2014
12:10 AM
|
0
|
0
|
1533
|
POST
|
Hi, I'm trying to display a cached basemap and have a user click on it to create a new graphic point. All I really want at this stage are the coordinates of the point which will then be passed into another system. So far I've taken the sample for the compact api that displays a map and added a bit extra code to listen for a click and draw a point on the map at that location and show an alert with the coordinates of the point. It seems to work on a PC but when I use an android phone and add a point, the point displays in the top left hand corner of the original map starting location (even if I pan away from there and add a point). On android the alert box that displays the coordinates of the user click point then shows the x and y values as NaN. Here's my code, any suggestions as to what I'm doing wrong would be greatly appreciated. Cheers <!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<!-- On iOS, as part of optimizing your web application, have it use the
standalone mode to look more like a native application. When you use this
standalone mode, Safari is not used to display the web content???specifically,
there is no browser URL text field at the top of the screen or button bar
at the bottom of the screen. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Controls the dimensions and scaling of the browser window in iOS,
Android, webOS, Opera Mini, Opera Mobile and Blackberry. width: controls
the width of the viewport initial-scale: controls the zoom level when the
page is first loaded maximum-scale: control how users are allowed to zoom
the page in or out user-scalable: control how users are allowed to zoom
the page in or out -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Sets the style of the status bar for a web application when in standalone
mode -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<title>Potholes</title>
<link rel="stylesheet" href="http://jsdev.arcgis.com/3.6/js/esri/css/esri.css">
<link rel="stylesheet" href="css/main.css">
<script>
var dojoConfig = {
mblAlwaysHideAddressBar : true
};
</script>
<script src="http://jsdev.arcgis.com/3.7compact/"></script>
<script>
require(["esri/map", "esri/layers/FeatureLayer", "esri/geometry/Point", "esri/SpatialReference", "esri/graphic",
"esri/InfoTemplate", "dojox/mobile", "dojox/mobile/parser", "esri/sniff",
"dojox/mobile/deviceTheme", "dojo/dom", "dijit/registry", "dojo/on", "dojox/mobile/ToolBarButton",
"dojox/mobile/View", "dojox/mobile/ContentPane"],
function(Map, FeatureLayer, Point, SpatialReference, Graphic, InfoTemplate, mobile, parser, has, dTheme, dom, registry, on) {
parser.parse();
mobile.hideAddressBar();
var xcoord = getUrlVars()["x"];
var ycoord = getUrlVars()["y"];
var location = new Point([xcoord, ycoord], new SpatialReference({ wkid:27700 }));
//var location = new Point(xcoord, ycoord);
//alert(String(xcoord));
//alert(String(ycoord));
var initialExtent = new esri.geometry.Extent({
"xmin" : 310000,
"ymin" : 660000,
"xmax" : 335000,
"ymax" : 680000,
"spatialReference" : {
"wkid" : 27700
}
});
var map = new esri.Map("map", {
//infoWindow:popup,
extent : initialExtent
});
if (xcoord != null && ycoord != null){
map.centerAndZoom(location, 7);
}
//declare basemap
var basemapUrl = "http://217.174.251.127/ArcGIS/rest/services/Basemaps/Basemaplargescale/MapServer";
//var basemapUrl = "http://88.208.222.252/ArcGIS/rest/services/Basemaps/basemap/MapServer";
//create and add new layer
var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
map.addLayer(basemap);
var infoTemplate = new InfoTemplate();
infoTemplate.setContent("Address: ${Address}<br/>"
+ "Street: ${StreetName<br/>"
+ "Postcode: ${Postcode}<br/>"
+ "Description: ${Description}<br/>"
+ "Status: ${Status}<br/>");
var featureLayer = new FeatureLayer("http://88.208.222.252/ArcGIS/rest/services/Transport/PotholesTest/MapServer/0", {
mode : FeatureLayer.MODE_ONDEMAND,
infoTemplate : infoTemplate,
outFields : ["*"]
});
map.addLayer(featureLayer);
map.on("load", mapLoadHandler);
var resizeEvt = (window.onorientationchange !== undefined && !has('android')) ? "orientationchange" : "resize";
on(window, resizeEvt, resizeMap);
//var graphicsLayer = new esri.layers.GraphicsLayer();
//add new symbol for user points
var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 12,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([0,200,0]), 2),
new dojo.Color([255,0,0]));
//add a new graphic when the user clicks, the coordinates will be passed to CRM
var mapclickHandler = on(map, 'click', function (evt) {
//only capture one click
dojo.disconnect(mapclickHandler);
var newGraphic = new Graphic(evt.mapPoint, symbol);
map.graphics.add(newGraphic);
alert("x coordinate = " + evt.mapPoint.x + ", y coordinate = " + evt.mapPoint.y);
});
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
function mapLoadHandler(evt) {
resizeMap();
registry.byId('mapView').on('AfterTransitionIn', resizeMap);
}
function resizeMap() {
mobile.hideAddressBar();
adjustMapHeight();
map.resize();
map.reposition();
}
function adjustMapHeight() {
//var availHeight = mobile.getScreenSize().h - registry.byId('header').domNode.clientHeight - 1;
var availHeight = mobile.getScreenSize().h;
if (has('iphone') || has('ipod')) {
availHeight += iphoneAdjustment();
}
dom.byId("map").style.height = availHeight + "px";
}
function iphoneAdjustment() {
var sz = mobile.getScreenSize();
if (sz.h > sz.w) {//portrait
//Need to add address bar height back to map
return screen.availHeight - window.innerHeight - 40;
/* 40 = height of bottom safari toolbar */
} else {//landscape
//Need to react to full screen / bottom bar visible toggles
var _conn = on(window, 'resize', function() {
_conn.remove();
resizeMap();
});
return 0;
}
}
});
</script>
</head>
<body>
<div id="mapView" data-dojo-type="dojox.mobile.View" data-dojo-props="selected: true">
<!--<div id="header" data-dojo-type="dojox.mobile.Heading"></div>-->
<div id="mapContainer" data-dojo-type="dojox.mobile.ContentPane">
<div id="map"></div>
</div>
</div>
</body>
</html>
... View more
12-03-2013
07:45 AM
|
0
|
2
|
549
|
POST
|
I can't get this sample to work either. I've set a proxy page according to these instructions: https://developers.arcgis.com/en/javascript/jshelp/ags_proxy.html I've downloaded the html file, edited the url of the proxy page to point to my proxy page and ran it locally. The basemap loads but when I click on "add" it brings up a blank grey page (except for the black header). I've just checked the url for the feature service that is used: http://sampleserver5.arcgisonline.com/ArcGIS/rest/services/LocalGovernment/CitizenRequests/FeatureServer/0 and it says "invalid url". I guess I'll try to create my own feature service to get going with this but it'd be nice to see a working example first. ESRI - any thoughts as to whether the above feature service will be sorted or not?
... View more
12-02-2013
07:32 AM
|
0
|
0
|
715
|
POST
|
Thansk for your reply Mike. Yeah I've seen that but I was aiming to embed the map in an iframe on our website without using the basic map viewer. Also I want each of the 10/11 layers in the map to be able to be turned on or off, without having to put each layer in it's own ArcGIS Server map service. I know I can do this with the javascript API, I was just looking for a quicker way with ArcGIS.com, I guess there isn't one?
... View more
12-09-2011
01:40 AM
|
0
|
0
|
1601
|
POST
|
Hi, On our website I want to embed a web map I've created with ArcGIS.com but I want the web map to have a table of contents that allows the user to turn on and off all of the layers in the map. Is it possible to turn layers on and off on the embedded web map? Are there any templates for it (I can't find one)? Thanks, Mike.
... View more
12-08-2011
02:36 AM
|
0
|
12
|
5114
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|