|
BLOG
|
In technical support, I spoke to lots of folks who wanted to display the latitude and longitude of the current mouse position continuously in their JavaScript applications when using a basemap with a custom projection. Out of the box the ArcGIS API for JavaScript supports reprojecting pretty much any coordinates you can think of, but if you aren't converting between WGS84 and Web Mercator, its necessary to leverage a geometry service in order to get some help with the math. Our Geometry Service is an awesome tool that help with all sorts of manipulations and analysis including buffering, calculating convex hulls, decreasing vertex density and reshaping and can work on a collection of features simultaneously, but in this scenario its kind of like bringing out a chainsaw to cut your sandwich in half. The time it takes to send off the request and wait for the response makes it infeasible to continuously reproject the current location of the mouse. Thankfully there is an open source JavaScript library called Proj4js that can help. After loading Proj4js and giving it some information about the two coordinate systems you'd like to reproject, you can get the answer you need directly in the browser. These are the basic steps you'll need to follow: 1. load Proj4js alongside the JSAPI in your application using an additional script tag <!-- load proj4js from CDN -->
<script src="//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.3/proj4.js"></script>
<!-- then load the ArcGIS API for JavaScript-->
<script src="//js.arcgis.com/3.11/"></script>
2. define two custom projections in a format that Proj4js will understand (check out the project in Github for more information on formatting) var wkid4269 = '+proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees';
var wkid26912 = '+proj=utm +zone=12 +ellps=GRS80 +datum=NAD83 +units=m +no_defs';
3. lastly, wire an event listener so that proj4js can calculate the reprojection each time the mouse moves over the map map.on("mouse-move", function(evt){
var reprojectedCoords = proj4(wkid26912, wkid4269, [evt.mapPoint.x, evt.mapPoint.y]);
console.log(reprojectedCoords);
});
you can find a live sample which displays latitude and longitude coordinates in an interactive UTM 12N map here: https://dl.dropboxusercontent.com/u/59331579/js/jsapi-proj4js.html
... View more
11-03-2014
09:02 AM
|
4
|
6
|
7768
|
|
POST
|
I don't think this "Place" has blogging enabled so feel free to check out the post I wrote over in GeoDev
Now its even easier to look into the source of Esri-Leaflet!
... View more
10-18-2014
03:28 PM
|
0
|
0
|
1035
|
|
BLOG
|
We just pushed out a new version of Esri-Leaflet and now its easier than ever to get familiar with the source code of the API. Steps: navigate to https://github.com/Esri/esri-leaflet/releases and download the Source code (zip) associated with Release Candidate 2 unzip the folder on your own machine navigate to the ‘debug’ folder and open ‘sample.html’ This application points at local source files that are organized in the same directory structure as the GitHub repository itself. This means that you can use the developer tools inside your browser to inspect the API source. I’ve always found that setting breakpoints and stepping through the code slowly makes the logic that’s being employed to talk to ArcGIS Server and ArcGIS Online hosted content a lot easier to understand. Ideally, you should probably consider configuring a local web server like Apache or IIS to develop with (so that you can load your applications using ‘http://’ protocol in a browser instead of relying on ‘file:///’), but it's just cool to say that digging into the source is as easy as 1, 2, 3
... View more
10-18-2014
03:15 PM
|
0
|
0
|
1855
|
|
BLOG
|
Slight correction: When signing into developers.arcgis.com with an Organizational account you won't see 'Account Settings' as an option under your own profile. That being said, all the capabilities Al mentioned in the post will be available.
... View more
10-15-2014
03:04 PM
|
0
|
0
|
843
|
|
BLOG
|
nice blog nixta! and not sure where you found that presentation, but you must have cool friends.
... View more
10-08-2014
04:27 PM
|
0
|
0
|
600
|
|
POST
|
as tim said, you don't need to call dojo.ready(init) anymore. simply placing a <script> tag referencing your .js file in an .html or .aspx page while trigger the require and its callback firing. see this example in the Resource Center. in the js file itself, the code from
parser.parse();
...//to
var gs = new GeometryService("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer");
fires immediately after all the AMD modules have been loaded successfully. to get a better idea of whats triggered when, i usually like to set breakpoints in the developer tools and step through manually.
... View more
10-01-2014
09:25 AM
|
0
|
1
|
1000
|
|
POST
|
because that widget is open source, it isn't too hard to tweak it to meet your needs and reference as a local AMD module instead of pointing at the one in the API. i've attached a sample project (with the changes i mentioned in my previous post) in case you'd like to take a look.
... View more
09-04-2014
09:21 AM
|
1
|
0
|
1641
|
|
POST
|
hi stan, good find. i wasn't able to workaround the issue using public events emitted by the widget, but it was possible to resolve the problem by updating the widget source itself by calling the method below from within the private method _inputClick() of the widget itself (near line 1205 of Geocoder.js)
this.get("map").disableKeyboardNavigation();
afterwards, we have to make sure it gets turned back on when the widget is no longer being used:
this.get("map").enableKeyboardNavigation();
the second method needs to be called within both blur() and _performTask() to ensure that keyboard navigation returns whether a search is performed or whether someone clicks on the widget and then just clicks back on the map. i was able to determine all this by downloading the widget source and pointing the simple sample at the local code. afterwards, setting breakpoints in methods that seemed relevant helped me narrow down where i actually needed to place my calls to map.disableKeyboardNavigation() hope that helps. i'll make sure we get the widget updated with this change in the next release!
... View more
09-03-2014
05:25 PM
|
2
|
2
|
1641
|
|
POST
|
As he stated, sachin was able to resolve his problem by defining an appropriate datum transformation for layers in his map document prior to publishing his map service. ArcGIS Help (10.2, 10.2.1, and 10.2.2) GIS Manual: Why Don;t My GIS Layers Line Up?
... View more
08-06-2014
11:30 AM
|
0
|
0
|
1353
|
|
POST
|
you're very welcome. as you can see from the code in that page, we aren't doing anything in the application itself to handle the reverse geocoding. based on your other post it sounds like you want to skip this part entirely, but if you really wanted to get that level of control i guess you could update the string manually using a method like updateStop()
... View more
07-18-2014
11:57 AM
|
0
|
1
|
1811
|
|
POST
|
if you don't want to geocode, it might be a better idea for you to wire up your own RouteTask and pass the stops based on the mapPoint returned by the map 'click' event instead of trying to use the widget... check out this sample for an example: Find routes with barriers and multiple stops | ArcGIS API for JavaScript
... View more
07-18-2014
11:44 AM
|
0
|
0
|
522
|
|
POST
|
you can retrieve values from a known field a couple different ways... attributes.FIELDNAME attributes["FIELDNAME"] the second syntax would be better for you if you want to substitute a variable.
... View more
07-10-2014
09:17 AM
|
2
|
2
|
1190
|
|
POST
|
hey matthew, please consider marking Jake's reply as the 'answer' to this thread when you have a minute.
... View more
07-10-2014
09:09 AM
|
1
|
1
|
1594
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-16-2014 02:35 PM | |
| 1 | 03-15-2013 04:25 PM | |
| 1 | 06-01-2016 10:51 AM | |
| 1 | 12-28-2015 04:46 PM | |
| 1 | 12-28-2015 05:26 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:22 AM
|