|
POST
|
Haha, Matt's right. My head was totally somewhere else her, sorry Chris.
... View more
11-18-2014
11:48 AM
|
1
|
0
|
2117
|
|
POST
|
You could try something like this.
// set custom extent
var initialExtent = new Extent({
"xmin": 777229.03,
"ymin": 1133467.92,
"xmax": 848340.14,
"ymax": 1185634.58,
"spatialReference": {
"wkid": 3435
}
});
// create map and set slider style to small **LEAVE OUT EXTENT HERE**
map = new Map("mapDiv", {
showAttribution: false,
sliderStyle: "small"
});
// geolocation functionality starts here
map.on("load", initFunc); // **SET LOAD LISTENER BEFORE ADDING TILED LAYER**
// add imagery
var tiled = new ArcGISTiledMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Aerial_2014_Tiled/MapServer");
map.addLayer(tiled);
function initFunc(map) {
map.setExtent(initialExtent); // **SET EXTENT HERE**
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(zoomToLocation, locationError);
watchId = navigator.geolocation.watchPosition(showLocation, locationError);
} else {
alert("Browser doesn't support Geolocation. Visit http://caniuse.com to see browser support for the Geolocation API.");
}
}
... View more
11-18-2014
11:06 AM
|
0
|
0
|
3189
|
|
POST
|
That is werd because the docs say that if you construct the map with an Extend and spatial reference,everything should work as long as all other layers match. map-amd | API Reference | ArcGIS API for JavaScript
If provided, the extent and projection of the map is set to the properties of Extent. Once the projection is set, all layers must be able to be drawn in the defined projection. The tiling scheme of an ArcGISTiledMapServiceLayer must match the projection of the map. The projection of the extent is honored when used in the map constructor.
What you may want to try Chris is don't initialize the extent in the constructor, instead wait for the map to load the tiled layer and then set the extent. It will inherit the spatial reference and default extents of the tiled layer and should accept the new extent. I had a similar issue in a local NAD spatial reference and in my case I think I just dropped the initial extent altogether, I could never get it to honor it and now I just have the map move to the previously loaded extent after it has been created.
... View more
11-18-2014
10:24 AM
|
0
|
9
|
3189
|
|
POST
|
This kind of depends on what you are looking to get out of it. GA will give you page/session stats, but not much details as to whether anyone ever clicks on a draw or search button. Check out Dave Bouwmans post on this subject, lots of good stuff there. His samples are in Backbone, but no reason you couldn't do same hooks in widgets. Only problem is this is only good for widgets you write. It would be much easier if widget interaction in WAB was done via dojo/topic, but I'm not sure if it is.
... View more
11-14-2014
08:51 AM
|
1
|
6
|
5096
|
|
BLOG
|
The ArcGIS API for JavaScript is currently at version 3.11. Since version 3.0, we all should have mostly abandoned using dojo/_base/connect. If you are really in a pinch working with an older library or maybe something in dojox, at least work with dojo/aspect. By now, everyone should be using dojo/on to listen to events. Maybe you're even using dojo/topic, but that's a whole other blog post. I'm not going to go into detail on how to use dojo/on, but I thought it would be neat to share a couple of ways you can extend dojo/on to do some cool stuff you might need for particular situations. Some time back, I had need to be able to toggle the eventlistener for a click event on my map. The first time I clicked the map, I want to do a selection and the second time I clicked the map I wanted to run a different method unrelated to the selection. There are a couple of ways I could have gone about this by using dojo/on#pausable or something. But I decided to just extend dojo/on to do what I needed.
define([
'dojo/on'
], function(on) {
'use strict';
var _on = on;
_on.switchable = function(target, type, listener1, listener2) {
var funcs
, index
, currentListener
, signal;
funcs = [listener1, listener2];
index = 0;
currentListener = funcs[index];
signal = _on(target, type, function() {
return currentListener.apply(this, arguments);
});
signal.toggle = function() {
index = 1 - index;
currentListener = funcs[index];
};
return signal;
};
return _on;
});
Then I was thinking about this recent thread and thought, Why can't I make a single use eventlistener? I'm sure this could come up in certain situations, so I put together a sample you can review. This one as well for a different approach. You can click on the Speak! button and get an alert message. Click on the Toggle button and click on Speak! again to get a different message. Click on the One time! button and an alert message will pop up in a second. The delay is optional, so you could change the delay to 100ms if you like. Try and click that same button again and nothing happens. This is just a quick example of stuff you could do depending on your situation and I thought would be fun to share. You can see more tidbits like this on my blog. Go forth and code my friends.
... View more
11-13-2014
11:22 AM
|
4
|
0
|
1903
|
|
POST
|
This is on the hacky end of doing things, but the animation is smooth, at leat in Chrome. JS Bin
require(["esri/map", "dojo/on", "dojo/domReady!"], function(Map, on) {
var map = new Map("map", {
center: [-118, 34.5],
zoom: 8,
basemap: "topo"
});
on(map, "dbl-click", function(e) {
var handle = on.once(map, "zoom", function() {
map.centerAt(e.mapPoint);
});
// timeout in case no zoom happened, so remove it pretty quickly
setTimeout(function() {
handle.remove();
}, 100);
});
});
I think the wording in the docs for enableDoubleClickZoom() are confusing. Maybe something more like "click location maintained within bounds when zoom occurs" or something like that.
... View more
11-12-2014
07:08 AM
|
0
|
0
|
3463
|
|
POST
|
The above examples could be tweaked a little for that.
var unique = {};
var distinctFeatures = featuresCollection.features.filter(function(feature) {
var oid = feature.properties.OBJECTID;
if (!unique[oid]) {
unique[oid] = oid;
return true;
}
return false;
});
featureCollection.features = distinctFeatures;
That's a quick and dirty way of doing it based on the example Ken provided.
... View more
11-10-2014
08:40 AM
|
0
|
1
|
1594
|
|
POST
|
Weird, seeing same thing. Never used this feature and tested it in 3.9 and 3.10 and doesn't work there either.
... View more
11-10-2014
08:18 AM
|
0
|
0
|
3463
|
|
POST
|
You are defining your modules in the wrong order.
require([
"esri/map",
"esri/dijit/LocateButton",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/ImageParameters",
"dojo/domReady!"
], function (
map, /*Should be Map, how you use in code*/ LocateButton, ImageParameters/*swap*/, ArcGISDynamicMapServiceLayer,/*swap, remove comma*/ ) {
You need to swap the ArcGISDynamicMapServiceLayer withe ImageParameters. Here is a working JSFiddle with your code cleaned up a bit. Edit fiddle - JSFiddle You just need to remember the order of how you name the modules matters with how you load them.
... View more
11-04-2014
08:54 AM
|
0
|
1
|
1697
|
|
BLOG
|
This was also usefultoI convert coords with the LocateButton before I realized it used the default geometry service if defined. May also want to point out Home -- Spatial Reference and EPSG.io: Coordinate Systems Worldwide to get the definitions. Great tip, thanks!
... View more
11-03-2014
09:21 AM
|
1
|
0
|
2489
|
|
POST
|
So there doesn't seem to be an easy way around this, even trying to do the query directly in ArcMap. What I ended up doing, since I am using this in a backend service anyway was to check if a single quote was in the request, create a substring up the index location of the single quote, do a LIKE request with a wildcard and from the results, find the one that matches the original request. It would look something like this in .NET.
string m_search = search;
bool hasQuote = search.Contains("'");
if (hasQuote == true)
{
m_search = search.Substring(0, search.IndexOf("'"));
}
// do API request and get response
// string where = "where=FIELDNAME LIKE '" + m_search + "%'";
var features = response["features"];
List<object> list = new List<object>();
for (int i = 0; i < features.Length; i++)
{
var feat = features;
var attr = feat["attributes"];
if (attr["FIELDNAME"] == search)
{
list.Add(attr);
}
}
return list;
It seems to be working ok so far and not's noticeably slower in my current queries. In case anyone else comes across this problem, that's how I figured it out.
... View more
10-31-2014
12:07 PM
|
2
|
0
|
728
|
|
POST
|
So I have some street data where a field I am searching on has some values that look like
135' S/O Main St
This is causing problems when trying to search for these with the ArcGIS REST API. I've tried using the following
135%27 S/O Main St
But that doesn't work either. I know they are there because I can search on the ID and they come back in results, but I need to search on the actual value. Any tips? Anyone run into this before? Thans.
... View more
10-30-2014
03:57 PM
|
0
|
1
|
3917
|
|
BLOG
|
Thanks for the questions! I just fixed the demos and updated them to use the latest 3.11 Esri JS API. odoe/esri-clusterfeaturelayer · GitHub The AGO URL I was using for demo has since been secured. It's kind of tough finding a URL with that many points to demo, but rest assured it handles it. I've now updated the sample with a service that does not require a login. It has the ability to add a MODE_SNAPSHOT just like a regular FeatureLayer. The default is true, so it will attempt to download ALL points and cluster them. The benefit here is that all data is then cached and no new requests are made. This is one of those things you'll need to play with in your dataset to see what works better. This demo seems to timeout on the requests sometimes. It takes a while to load. I'll look into replacing this with a smaller dataset, but the idea was to show that it could actually cluster them. Once all the polygon data is downloaded, the ClusterFeatureLayer will convert the polygons to points in order to cluster them. This process is actually fast, but making all the requests including the geometries can take a while. Here is a current working demo using about 2,300 points. Cluster Like I said, the slowest part is actually downloading the data, clustering is pretty quick. Please provide any feedback or report any bugs, thanks!
... View more
10-24-2014
08:27 AM
|
0
|
0
|
840
|
|
POST
|
If you are able to publish the data to ArcGIS Server or ArcGIS Online, I extended the original clustering example to work more like a FeatureLayer via URL, which includes caching and working around the default 1000 feature limit. I put a post up on it here. Let's talk clusters.
... View more
10-21-2014
06:40 AM
|
0
|
1
|
2789
|
|
POST
|
Thanks Patrick! I think this will work, because ultimately what I end up doing is an attribute and spatial query of the data. I keep forgetting about L.esri.get, ha.
... View more
10-16-2014
09:38 AM
|
0
|
0
|
2630
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a week ago | |
| 2 | 05-19-2026 02:12 PM | |
| 1 | 04-24-2026 11:01 AM | |
| 2 | 04-21-2026 07:06 AM | |
| 1 | 02-27-2026 06:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|