|
POST
|
If you're dealing with GeoJSON in non-WGS84 coords, you'll need to run it through Proj4JS. Luckily, there is a Proj4Leaflet plugin you could use too. How to use it with GeoJSON. There's an example of using it with non-mercator tiles with esri-leaflet. - note, I've had mixed results with tiles. Here's a post on using it with EsriJS. You can find project definitions at these locations. Home -- Spatial Reference EPSG.io: Coordinate Systems Worldwide Hope that helps.
... View more
02-24-2015
08:35 AM
|
1
|
1
|
6595
|
|
POST
|
I think it's this line. map.popup.resize(200, 75); I think what you meant was map.infoWindow.resize(200, 75); Once I fixed that, I was able to get the load function to work and it zoomed to an address I passed in the URL. Hope that helps! Thanks!
... View more
02-19-2015
03:16 PM
|
1
|
1
|
2255
|
|
POST
|
I wanted to do the online, but that's the same week as devsummit and they do not record the sessions. Maybe another time.
... View more
02-19-2015
02:01 PM
|
0
|
0
|
1292
|
|
POST
|
I can't really test it, but if you look at the Esri sample, the symbology for selected items is set in the Popup that is passed to the map. ArcGIS API for JavaScript Sandbox You could also try manually setting the symbology in your doIdentify method. feature.setSymbol(symbol); // you define symbol near the top I'm not sure why it was working and stopped working for you, but I think either of the above solutions should do the trick... I think.
... View more
02-19-2015
01:54 PM
|
0
|
1
|
587
|
|
POST
|
I copied the code from that page and tested it out. First thing I saw was that you are not returning geometry with the IdentifyResult. identifyParams.returnGeometry = false; I changed it to true. Second thing I noticed was the results are not actually added to the map. They are saved to a cityResults and countyResults, but then nothing is done with them. I don't know what logic you wanted for adding the graphic, so I just tweaked the code in a JSBin to do this. JS Bin - Collaborative JavaScript Debugging Hope that helps. Thanks.
... View more
02-19-2015
08:23 AM
|
2
|
5
|
2341
|
|
POST
|
That code uses the esri/tasks/locator task to do the address lookup. The Locator task is what powers the Geocoder widget. So in the Geocoder widget (which is on github too) it's doing something very similar to that code. So it builds address parameters which assume the Geocoder service takes a single line as the address. You set the outSpatialReference so the geocoded results come back in the same spatial reference as the map. And the locator has an addressToLocations method that does the address lookup. However, the template app already has a Geocoder widget in it, actually it has two for some reason, it also has a mobile it toggles between depending on screen size or device, whatever. So when I saw that, I figured why reinvent the wheel, since you can use the Geocoder find method and select method to get the same result. Hope that clears it up a bit. Maybe I can do a blog post on this subject too. Thanks!
... View more
02-19-2015
08:07 AM
|
1
|
1
|
2255
|
|
POST
|
Not necessarily. GeoJSON is the spec for spatial data over the web. I don't know exact history, but I'm guessing Esri defined their spec of (not the official name) EsriJSON (which is part of their GeoServices spec). Like I said, not sure of the discrepency or reasons behind it, maybe a lot of it comes from ArcObjects stuff built up over the years. Anyway, it makes sense that some would provide you with GeoJSON data for location information. If you still need to work with Esri data and this GeoJSON data you have, you may want to look at using esri-leaflet as Leaflet uses GeoJSON out of the box and esri-leaflet adds the ability to use ArcGIS services with it.
... View more
02-19-2015
07:43 AM
|
0
|
1
|
3983
|
|
POST
|
I hadn't used a template app in a while, so I forked it and added the address parameters via URL for my version. odoe/public-information-map-template-js · GitHub The only changes I made were in the main.js file. I added the esri/urlUtils modules. define([
...
"esri/urlUtils"
],
function(
...
urlUtils
) {
... Then I added this at the end of the _init method, after this drawer.resize() call. _init: function() {
...
this._drawer.resize();
// MODIFICATIONS
// check URL for address search params
var params = urlUtils.urlToObject(document.location.href);
if (params.query && params.query.address) {
var address = params.query.address;
// You could also set the value of the geocoder input box
// or just set the value, your preference
//this._geocoder.inputNode.value = address;
this._geocoder.value = address;
this._geocoder.find().then(lang.hitch(this, function(response) {
if (response.results.length) {
this._geocoder.select(response.results[0]);
}
}));
}
} There is also a _modileGeocoder that gets built during this whole process, but I didn't bother using that one. It would work similar if you wanted it to work with the mobile version. Also of note, what I thought was odd behavior. The find method of the geocoder does not zoom to the first result, you have to manually do that with select(result) after running find.
... View more
02-19-2015
07:14 AM
|
2
|
3
|
5569
|
|
POST
|
In that case, you could do it in the _init method of main.js At this point, the map is already loaded as other components are loading, so maybe near the end of _init, do the steps to get the URL parameters and do the geocoding.
... View more
02-18-2015
07:46 PM
|
0
|
5
|
5569
|
|
POST
|
My bad, you're right. I missed that bit in your sample GeoJSON. Depending on how much data you have, you could run it through proj4js to convert the coordinates. There's a post here on GeoNet on how you might work with it. If you need to get hands on, this library has some code that may help to just convert the GeoJSON directly to EsriJSON regardless of projection. You basically just need to change the structure of the data.
... View more
02-18-2015
02:55 PM
|
0
|
1
|
3983
|
|
POST
|
You may want to take a look at Terraformer. It can convert data between GeoJSON and ArcGIS JSON Objects. There's also this geojson-layer that was put up not too long ago. Haven't used it, but it looks pretty good.
... View more
02-18-2015
02:43 PM
|
0
|
3
|
3983
|
|
POST
|
Here is how you might do it. // assume URL looks like http://myserver.com/flexviewers/actmap/index.html?address=15 Fordham St, Pocatello, Idaho
// wait for map to load
map.on("load", function() {
// get the URL parameters
var params = urlUtils.urlToObject(document.location.href);
// check that parameters exist in the URL
if (params.query && params.query.address) {
var address = params.query.address;
map.graphics.clear();
// build address params
var addressParams = {
"SingleLine": params.query.address
};
locator.outSpatialReference = map.spatialReference;
var options = {
address: addressParams,
outFields: ["Loc_name"]
};
// send to locator
locator.addressToLocations(options);
}
}); Here is a JSBin where I just edited an Esri example on how to geocode an address. JS Bin - Collaborative JavaScript Debugging Unfortunately due to the way JSBin and even JSFiddle run JS apps, I don't think you can grab the parent browsers URL, but that could should work in a standalone application. Hope that helps
... View more
02-18-2015
01:10 PM
|
1
|
8
|
5569
|
|
POST
|
Yeah, you'll need to wire up the code yourself to pull the URL parameters and do the address searching. This works similar to how you might use dojo/router, which I wrote about here. The steps would be: Wait fo the map to load Check for URL parameters If parameters for address search provided, send address to Geocoder widget Hope that helps.
... View more
02-18-2015
10:32 AM
|
1
|
11
|
5569
|
|
POST
|
The easiest way would be to use the esri/urlUtils module to turn URL parameters into an object. This should do all the heavy lifting for you. I'm sure in there some where it utilizes dojo/io-query to parse the URL given document.location.search
... View more
02-18-2015
09:45 AM
|
1
|
0
|
5569
|
|
BLOG
|
So you're chugging away at your awesome ArcGIS JavaScript application. You have some nice custom tools in place, you may even have some search capabilities going on, this thing looks cool. You go to click on a feature on the map and you've got all the important field information... except that you have numbers where maybe values should be showing up? Well that the heck is that all about? What does that number even mean? So you go and look at the map service and you see that this field has a domain associated with it. Maybe you look at another application where this service is edited and you notice that the attribute inspector in the editor has the correct domain values and now you're just scratching your head wondering how to get those values. Don't worry, they're there...somewhere. Field Fishing Lucky for us, the FeatureLayer has a fields property we can use to get not only the domain values, but also the alias names, which are nice human readable descriptions of the field. It's not exactly in the optimal format to just drop in and use, but with a little work you can make it handle your data with ease. You may want to create a hash table to easily associate the coded values with the domain values. var fieldMap = {};
featureLayer.on('load', function() {
// iterate the fields of the Layer
featureLayer.fields.filter(function(x) {
return !!x.domain; // force value to boolean. only care about domains here
}).map(function(x) { // map fields with domains
fieldMap[x.name] = {}; // hash table
fieldMap[x.name].values = {}; // will hold domain values
fieldMap[x.name].alias = x.alias; // nice display name
x.domain.codedValues.map(function(a) { // map over the codedValues
fieldMap[x.name].values[a.code] = a.name; // save domain
});
});
}); The key here is to iterate over the fields of the layer and store the coded value as the key to the domain value. This will make lookup of the values much easier in the next step. We have a method that defines the content of the popup when it gets clicked. We can use the hash table of domain values to make this a simple task. function getTextContent(graphic){
// get keys of the attributes
// *Note - you may need a shim for your browser
var elems = Object.keys(graphic.attributes).map(function(x) {
var attr = graphic.attributes ;
var field = fieldMap ;
if (field) {
return "<b>" + field.alias + "</b>: " + field.values[attr];
} else {
return false;
}
}).filter(function(x) { return x; }); // only return valid results
return elems.join('<br />');
} So in this sample, we use Object.keys (note - you may need to shim this method) to get the keys of the attributes. You can use the keys to get the matching set of coded and domain values, along with the alias for the field, and compose a simple DOM element to display in the InfoWindow. The result of this technique now display the InfoWindow like below. You can see a full demo of this sample here. It just need a little massaging Sometimes when working with data from ArcGIS Server and such you may need to massage your results to display as you want them to. It's not difficult to do and once you do this a couple of times, it becomes like second nature, but I know from experience how frustrating it can be to try and navigate the documentation to try and solve this simple task. I hope this saves you a step or two. This isn't necessarily the only way to accomplish this, but I thought it was the most straight-forward example. For more tips and tricks on geodev, check out my blog.
... View more
02-18-2015
08:05 AM
|
0
|
0
|
1648
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | Wednesday | |
| 1 | 3 weeks ago | |
| 2 | 2 weeks ago | |
| 2 | 05-19-2026 02:12 PM | |
| 1 | 04-24-2026 11:01 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|