POST
|
I am not sure if it is possible to do this. I was under the impression that all tiled layers had to use the same spatial reference. After a bit of searching I found this: Set custom extent and spatial reference | ArcGIS API for JavaScript
At versions 1.0 and 1.1 of the ArcGIS JavaScript API, any map service layers you used were required to correspond with the map's spatial reference. Beginning at version 1.2, you can use dynamic map services that have a different spatial reference from the map. Although this gives you more flexibility of the layers you can use, the projection on the fly negatively affects performance.
Cached (tiled) layers in your map must still match the map's spatial reference.
... View more
07-29-2014
05:09 PM
|
0
|
0
|
854
|
POST
|
Marla is correct that the proxy setting would be causing the issue when attempting to run this from a local file. The proxy is only used for very large requests and you can comment it out for testing purposes:
//urlUtils.addProxyRule({
// urlPrefix: "route.arcgis.com",
// proxyUrl: "/sproxy"
//});
However, in your live site you should use a proxy. I have also noticed that when you run this sample from a local file you will be prompted for an ArcGIS Online account to use the ESRI World Route service. You will either need to have an account or be running your own routing service on ArcGIS Server. If you are running your own service you would need to change the URL when creating the Route Task:
// This uses the ESRI routing service
routeTask = new RouteTask("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World");
Owen www.spatialxp.com.au
... View more
07-29-2014
03:58 PM
|
0
|
0
|
809
|
POST
|
Do you have a common key field in both datasets? If so you could join the measured coordinates data to the GPS data using this field. This assumes that you have a GPS point for each of your measured points. Otherwise: 1. Add your GPS points into an empty document in ArcMap. 2. Add your measured coordinates data. 3. Use the Spatial Adjustment toolbar to fit your data to the known GPS points.
... View more
07-29-2014
03:21 PM
|
0
|
0
|
642
|
POST
|
Nothing is forever Something will eventually replace Javascript - just not in the foreseeable future.
... View more
07-29-2014
03:15 PM
|
0
|
0
|
688
|
POST
|
What context are you looking to do this in? - for example, when a user selects a feature in ArcMap or within a geoprocessing script. There are some options in the arcpy.mapping python module for doing this kind of thing.
... View more
07-29-2014
03:08 PM
|
0
|
0
|
311
|
POST
|
How does the program creates the values of lat an lon when there is only a graphical expression of the data but no coordinates For point layers using a geographic coordinate system the lat and lon are stored in the Shape field. The graphic on the map is derived from the Shape field data. When you calculate x and y values into other fields, ArcMap gets these values from the Shape data and inserts them into the attribute table. In the case of your data something appears to be wrong. The calculated lat and lon values do not seem to correspond with the data in your group of points that are all around 49N and 17E. I have a group of points (point shapefile) that I collected in the field. They all has position relationship though they don't contain information about their global coordinates (I didn't have gps unit for that task). If you are trying to match the data to the other layer that you collected with a GPS then Anthony is correct and you should use the Spatial Adjustment toolbar. This allows you to select points in your data and link them to their actual location. Hope this helps, Owen www.spatialxp.com.au
... View more
07-29-2014
03:02 PM
|
0
|
0
|
642
|
POST
|
But this method only removes the layer not the extent and it create problem when I add a new layer. What is the problem that the previous map extent creates when adding the new basemap layer? - is the spatial reference different?
... View more
07-28-2014
06:05 PM
|
0
|
2
|
854
|
POST
|
Hi Laura, Check out the Geocode an address | ArcGIS API for JavaScript sample. This sample geocodes an address then zooms to the location. You should be able to insert your geoPlace variable into the locate function - something like:
function locate() {
map.graphics.clear();
var address = {
"SingleLine": geoPlace
};
locator.outSpatialReference = map.spatialReference;
var options = {
address: address,
outFields: ["Loc_name"]
}
locator.addressToLocations(options);
}
Hope this helps, Owen www.spatialxp.com.au
... View more
07-28-2014
05:31 PM
|
0
|
1
|
422
|
POST
|
Hi Steve, One issue with the code is that the required ESRI API modules are not being loaded. A while ago ESRI changed the way that developers reference the required API modules:
// legacy
dojo.require("esri.map");
// AMD
require(["esri/map", ... ], function(Map, ... ){ ... });
More info available at Dojo and AMD. It can be a bit confusing as some of the documentation still shows the legacy way of using the API - such as the Working with the Route Task page. Your example seems to be based on the code on this page. The old way was to create a Route Task was:
var routeTask = new esri.tasks.RouteTask("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route");
The new version of this would be:
require([
"esri/tasks/RouteTask", ...
], function(RouteTask, ... ) {
var routeTask = new RouteTask("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route");
...
});
I would suggest basing your code on this newer AMD style example from ESRI: Find routes with barriers and multiple stops | ArcGIS API for JavaScript Hope this helps, Owen www.spatialxp.com.au
... View more
07-28-2014
03:02 PM
|
0
|
4
|
809
|
POST
|
You could create a custom JSON object containing your text symbol and its location (point geometry), for example:
{
"pt":{
"type":"point",
"x":-13046161.8651223,
"y":4036389.8461467917,
"spatialReference":{"wkid":102100,"latestWkid":3857}},
"txt":{
"type":"textsymbol",
"x":0,
"y":0,
"text":"380 New York St, Redlands, California, 92373",
"rotated":false,
"kerning":true,
"color":{"b":102,"g":102,"r":102,"a":1},
"font":{
"size":14,
"style":"normal",
"variant":"normal",
"weight":"bold",
"family":"Helvetica"},
"horizontalAlignment":"center",
"align":"middle",
"xoffset":0,
"yoffset":8
}}
This could be stored in the database for each text element. To create the data to store you could use a function like this:
// Create a custom JSON object
function textSymbolToJSON(pt, ts) {
var txtSym = {
"pt":pt,
"txt":ts
};
return JSON.stringify(txtSym);
}
Pass the Point and TextSymbol into the function and store the JSON string in your database. To build the text symbol from the JSON object again use something like this:
// Create the text symbol from JSON data
function textSymbolFromJSON(json) {
var obj = JSON.parse(json);
var pt = new Point(obj.pt);
var ts = new TextSymbol(obj.txt);
map.graphics.add(new Graphic(pt, ts));
}
I have created a basic sample of this concept (without a database). Open the sample page, click on Locate - this will populate the custom JSON data. Try modifying the custom JSON data directly then click on Recreate to view the results. Hope this helps, Owen www.spatialxp.com.au
... View more
07-28-2014
02:00 AM
|
0
|
2
|
1240
|
POST
|
You could destroy and recreate the map object to clear the basemap and all other map properties such as extent, scale, etc.
// Destroy existing map
map.destroy();
map = null;
//Create new map
map = new Map("map", {
…
});
Based on this sample from ESRI.
... View more
07-28-2014
12:15 AM
|
0
|
4
|
854
|
POST
|
Hi JD, As Xander points out you will need to modify your script to use the toolbox parameters. If you want to set default values for your script parameters you can do this in the Script Properties: Owen www.spatialxp.com.au
... View more
07-27-2014
06:44 PM
|
0
|
0
|
598
|
POST
|
Hi Chris, I haven't tried this using the Android SDK QueryParameters. The example in the developer help shows a query with no quotes at all around the field name - have you tried without quotes around the field name? The developer help example was: 'POP2000 > 500000'
... View more
07-27-2014
06:23 PM
|
0
|
1
|
744
|
POST
|
This may also be the issue with your query - try using double quotes around the field name. In ArcMap the field name is normally enclosed in double quotes and the query value for strings is in single quotes. For example in a test data set I can run the following Select By Attributes query: "HydroName" = 'Richmond River' --> returns 44 records However, if I change the query: 'HydroName' = 'Richmond River' --> returns 0 records Interestingly, the second query can be verified and runs but returns no records. I also tried this in ArcMap against one of the ESRI sample feature services DamageAssessment (FeatureServer) "inspector" = 'Fred' --> returns 37 records 'inspector' = 'Fred' --> returns 0 records UPDATE: Just out of interest, I also tried using no quotation marks around the field name and the query worked: inspector = 'Fred' --> returns 37 records
... View more
07-27-2014
05:59 PM
|
0
|
3
|
744
|
POST
|
I would also suggest refactoring your code to use a function that you can call from the button click or map click events. Your map click event handler can pass the map click point to the new function:
// solve the closest facility for the map click location
function mapClickHandler(evt) {
var mapPt = evt.mapPoint;
solveClosestFacilities(mapPt);
}
Your button click event handler can pass the geolocation point to the new function:
// wire up the button click event
dom.byId("search-geolocation-btn").onclick = geolocationHandler;
// this function would be wired up to your button click event
function geolocationHandler() {
if (pt){
solveClosestFacilities(pt);
} else {
alert("Geolocation point is not available.")
}
}
The new function is basically the same as your old mapClickHandler function - note the minor changes:
// solve the closest facility for the search point (thie point comes from the map click location or the geolocation)
function solveClosestFacilities(searchPt) {
clearGraphics();
//Creating directions text in directionsDiv
dom.byId("directionsDiv").innerHTML= "";
//Add incident from user's current location on map click...again maybe change to when a button is clicked
var inPoint = new Point(searchPt); // note this line has changed
var location = new Graphic(inPoint);
incidentsGraphicsLayer.add(location);
// the rest is the same as your previous code...
}
I have created a modified version of your code on JS Bin to show these changes in action. Hope this helps. Owen www.spatialxp.com.au
... View more
07-26-2014
06:33 PM
|
0
|
1
|
585
|
Title | Kudos | Posted |
---|---|---|
1 | 10-07-2014 06:13 PM | |
1 | 08-25-2015 02:04 AM | |
1 | 10-07-2014 03:54 PM | |
1 | 08-07-2014 09:19 PM | |
1 | 03-04-2015 02:02 PM |
Online Status |
Offline
|
Date Last Visited |
07-21-2021
06:32 PM
|