Archive

Posts Tagged ‘ESRI JavaScript API’

Seeking a GIS Developer to Join Our Team

September 13th, 2010 Comments off

This position has been filled.

My development team is currently looking for a mid-level GIS Developer.

We are looking for someone that has experience in ArcObjects and ArcGIS Server development and administration but that is also interested in moving more into “Web 2.0″ GIS application development (RESTful services, ArcGIS Server JavaScript API, Dojo, ASP.NET MVC, WCF etc.).

Our team develops primarily in C# and makes extensive use of the Visual Studio Team System. We develop software using the Scrum software development framework, allowing us to be agile and to work closely with our customers.  We have a team room available to us that provides an excellent team collaboration space.

We value high quality software and we use continuous integration (automated builds, automated unit testing, static code analysis and automated test deployments) to allow us to develop software rapidly.

If you think you have the skills and you are interested in shaping the future of Denver’s GIS program apply online at http://www.denvergov.org/jobs.

Note: The position is listed as ‘Associate GIS Developer’.

Securing ArcGIS Server

June 24th, 2010 1 comment

A recent post on the ArcGIS Server blog provides a summary of security measures that are frequently overlooked when securing ArcGIS Server services.

A measure that I wasn’t aware of is the ArcGIS Server Proxy Page:

Custom applications built using the ArcGIS Web APIs (JavaScript, Flex, etc) that access ArcGIS token-secured resources require a valid token to access the resource. If this token is embedded in the application, it can be easily viewed through the Web browser.

ESRI provides a proxy page that can be used to request ArcGIS tokens. Download and configure this proxy page for use in your Web mapping application. The use of the proxy page ensures that there is no transmission of the token over the network between the Web server and the Web client.

For an example, see the JavaScript proxy page.

We’re Hiring! (Senior GIS Developer)

May 26th, 2010 Comments off

This position has been filled.

My development team is currently looking for a talented Senior GIS Developer to join us in building innovative solutions for the Geoweb.

We are looking for someone that has strong “Web 2.0″ development experience including strong JavaScript skills (Dojo and/or jQuery experience is a big plus).

Our team is skilled in the latest technologies including ArcGIS Server, the ArcGIS Server JavaScript API, Dojo, ASP.NET MVC, WCF (SOAP and RESTful JSON services), Entity Framework and the Visual Studio Team System.

Our team develops software using the Scrum software development framework, allowing us to be agile and to work closely with our customers.

We value high quality software and we use continuous integration (automated builds, automated unit testing, static code analysis and automated test deployments) to allow us to develop software rapidly.

We now have a team room (new last year!) that provides an excellent team collaboration space.

If you think you have the skills and you are interested in shaping the future of Denver’s GIS program apply online at http://www.denvergov.org/jobs.

ArcGIS Server JavaScript API 2.0 Now in Beta

March 23rd, 2010 Comments off

The public beta of the ArcGIS Server Javascript API 2.0 has been released.

Here is a summary of what’s new from the SDK documentation.

Note that 9.4 is still showing up in some of the documentation even though the name has been changed to 10.

Feature layers

FeatureLayers are a new type of operational layer that can be created and added to your map. FeatureLayers extend graphics layers and work against a layer or table in a MapService or FeatureService.

Editing

At 9.4 a new service, FeatureService, was added to support template style editing. Several widgets have been added to support editing including the Editing widget, a configurable out of the box editing solution.

Time aware layers

Support has been added for time-aware layers and a new TimeSlider widget. Now you can query or display your time-aware layers using a particular slice of time. The TimeSlider provides an easy way to visualize temporal data. For more information, see Working with time-aware layers.

Network Analyst

Support for closest facility and service area.

Image Server

Enhanced image server capabilities.

Mapping Enhancements

Several mapping enhancements were added at 9.4 including:

  • Query enhancements include the ability to query for IDs which can be used to include paging in applications. Query performance has been improved by adding support for fast JSON and AMF formats.
  • Support for stand-alone tables.
  • Ability to expose and query relationships.
  • The identify and find operations support layer definitions.

ArcGIS JavaScript API Version 1.6 Released

March 1st, 2010 1 comment

An update to the ArcGIS Server Javascript API has been released.

We *just* ordered and received a copy of the 1.5 API on DVD so now we’ll need to wait until the 1.6 is available to get an updated DVD.

Here’s hoping ESRI will make it available as a download in the future..

Bootstrapping the ArcGIS Server JavaScript API

October 26th, 2009 1 comment

On a project my team is currently working on with we came across the need to bootstrap the ArcGIS Server JavaScript API.  What I mean by ‘bootstrapping’ is the ability to load the JavaScript API during script execution after page load without loading it declaratively in the <head> of the HTML page.

To better describe the need for this here is a summary of our requirements:

  1. We wanted the ability to embed our live maps (and map related capabilities) as widgets in other HTML pages throughout our company website
  2. We wanted the ability to embed these live maps as a stand-alone snippets of HTML without having to modify the page <head>.  This would allow content authors to embed maps without having access to modify anything but a container element on the page.
  3. We wanted the ability to wrap these up in a container (in our case this will probably be a DotNetNuke module)
  4. We didn’t want the content author to have to know anything about the actual implementation of the map engine.  This future-proofs the implementation as the content author does not have to refer to a specific version of the JavaScript API or even know that the JavaScript API is the engine behind the map.
  5. We didn’t want the loading of the embedded map to have direct impact on the loading of the parent page (asynchronous loading)
  6. We didn’t want to deal with iframes for embedded map widgets

What we wanted was the ability to include a snippet like the following in any page and get a fully dynamic map widget (Note: I have renamed the objects/namespaces to make this description generic. myMapApi is used as the base namespace for these examples):

<!-- Start map widget -->
<script language="javascript" src="http://www.website.com/maps/api.js">
<div id="map" style="width: 600px; height: 400px;"></div>
<script type="text/javascript">
    var map = new myMapApi.Map("map");
</script><br />
<!-- End map widget -->

The ArcGIS Server Javascript API is based on Dojo. When the Javascript API is normally loaded (as a script in the page header) the script will automatically load Dojo and Dojo will then bootstrap the resources that it needs. Dojo includes the ability to load scripts on the fly (using dojo.require) which is the method that is used to load the modules that are required for the current page.

Because Dojo is bootstrapped and modules can be loaded on demand, Dojo provides an addOnLoad method which allows you to ensure that everything has been loaded before proceeding with the execution of code that depends on Dojo components.

The addOnLoad method accepts a callback argument that is used to ‘call back’ when the following conditions are met:

  1. The DOM is loaded
  2. All Dojo modules are loaded (and their recursive dependencies)

If you take a look at the basic map sample from the Javascript API docs you will see the general sequence of events:

  1. Add the Javascript API script reference to the page head
  2. Run dojo.require for all necessary Dojo modules
  3. Create an init method to be called back when everything is loaded
  4. Pass this init method to dojo.addOnload to kick off the execution of the script when the page is loaded.

This works great when you include the ArcGIS Server Javascript API directly in the page head but we wanted to do this by wrapping the Javascript API in our own application API. As noted above, consumers of our maps would then not have to know anything about the ArcGIS Server Javascript API or Dojo.

To get around the async loading that occurs when scripts are included dynamically we implemented a mechanism that is similar to the Dojo addOnLoad.

Here is a sample snippet that would appear in a web page to include our map widget:

<!-- Start map widget -->
<script language="javascript" type="text/javascript" src="api.js"></script>	
<div id="map" style="width: 600px; height: 400px;"></div>
    <script type="text/javascript">
        function init() {
            var map = new myMapApi.Map("map");
        }
        myMapApi.onLoad(init);
</script>
<!-- End map widget -->

Similar to Dojo, the onLoad method accepts a callback method that our API can call when everything it needs has been loaded. The code in our API can then call the callback whenever the ArcGIS Javascript API has been loaded dynamically and whenever Dojo is fully loaded.

The basic challenge at this point was to determine how to load the ArcGIS Server Javascript API dynamically and then determine when it was fully loaded so that the callback method could be called.

Here is what we came up with:

// Create the namespace
if (myMapApi == null || typeof (myMapApi) == 'undefined') { var myMapApi = {}; }

// ESRI Javascript API bootstrapper
(function() {

    // Configure Dojo onLoad so that it works after the page's
	// onload event has already occurred
    djConfig = {
        afterOnLoad: true,
        addOnLoad: function() {
            myMapApi.scriptsLoaded = true;
            if (typeof (myMapApi.onLoadCallback) != 'undefined') {
                myMapApi.onLoadCallback();
            }
        }
    };

    // Dynamically load the Javascript API
    var scriptElement = document.createElement('script');
    scriptElement.type = 'text/javascript';
    scriptElement.src = 'http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.5';
    document.getElementsByTagName('head')[0].appendChild(scriptElement);
	
	// Dynamically load a Dojo stylesheet
    var linkElement = document.createElement("link");
    linkElement.type = 'text/css';
	linkElement.rel = 'stylesheet';
	linkElement.media = 'screen';
    linkElement.href = 'http://serverapi.arcgisonline.com/jsapi/arcgis/1.5/js/dojo/dijit/themes/tundra/tundra.css';
    document.getElementsByTagName('head')[0].appendChild(linkElement);

})();

// Create an onLoad event to call the client back on when
// dependant scripts have been loaded 
myMapApi.onLoad = function(onLoadCallback) {
    myMapApi.onLoadCallback = onLoadCallback;
    if (myMapApi.scriptsLoaded) { myMapApi.onLoadCallback(); }
}

// The Map class creates and loads the actual map in the parent container
myMapApi.Map = function(containerId) {
	
	// Get the container in which to create the map
	var container = dojo.byId(containerId);
	
    // Create a div for the map
    var mapDiv = document.createElement("div");
    mapDiv.className = "tundra";
    mapDiv.id = "mapdiv";
	container.appendChild(mapDiv);
    mapDiv.style.width = container.offsetWidth;
    mapDiv.style.height = container.offsetHeight;

    // Create the map
    var map = new esri.Map("mapdiv");

	// Add a service to the map
	var service = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer";
    var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer(service);
    map.addLayer(tiledMapServiceLayer);
	
	return this;
}

Here is a quick breakdown of how this works:

Line 2: Set up the myMapApi namespace.

Line 5: This code is implemented entirely as an immediately executable anonymous function to avoid creating any variables within the scope of the page. You can see a description of this technique here.

Line 9-17: The djConfig object is the key to getting this technique to work. The default behavior of addOnLoad is to fire when all dependencies are loaded (including the page DOM). As a result, if the DOM is already loaded the addOnLoad event will not occur. In many cases with a widget (sometimes depending on the browser) the DOM may already be considered to be loaded and the addOnLoad will not fire. The afterAddOnLoad property allows this behavior to be ignored and addOnLoad will fire whenever Dojo dependencies are loaded.

Line 11-16: This anonymous functions defines the addOnLoad behavior. In our case we note that the Javascript API is loaded and then we call the callback (if it is has been provided). Depending on the timing of the page load the callback may or may not have been provided at this point.

Line 19-23: Dynamically load the JavaScript API

Line 26-31: Dynamically load the tundra theme

Line 37-40: This anonymous function allows the consuming page (the page the contains the widget) to provide the callback function. A reference to the callback is kept in the event that the JavaScript API has not been loaded yet (at which point it will then be called on line 14. If the Javascript API is already loaded (as evaluated on line 39, the callback will be called.

Line 43-65: This class creates the div that will be used for the map, news up an esri.Map, and loads a map service into the div.

And that is basically it..

Here is the output from Firebug showing the loading sequence:

Bootstrapping the ESRI Javascript API - Firebug Output

I have also posted a working example of this technique. This has been tested to work in IE 7, FireFox 3.x and Chrome 3.x. If you find that it works (or doesn’t work) please let me know. Suggestions or other ideas are also welcome!

ArcGIS Server JavaScript API 1.5 Released

October 2nd, 2009 Comments off

An update to the ArcGIS Server Javascript API has been released.

Of the most notable updates, this release fixes the Firefox 3.5 picture marker bug and updates the Dojo toolkit to version 1.3.2.

Read the what’s new for more details.