Working with esri.graphics

Few common scenarios when you are working with the graphics layer (@ version 1.3) in the ArcGIS Server JS API

1. map.graphics returns the graphics layer
2. map.graphics.graphics returns the array of graphic elements (geometry, symbol, attribute, infotemplate) added to the graphics layer

To remove all graphic elements in the graphic layer
map.graphics.clear();

To show/hide specific graphic element
map.graphics.graphics[index].show();
map.graphics.graphics[index].hide();

To check if any specific graphic element is being shown or not:
// 'none' is hidden and 'block' is visible
map.graphics.graphics[index].getDojoShape().rawNode.style.display

Loop through all the graphic elements
var graphics = map.graphics.graphics;
for (var i=0; i< graphics.length; i++)
{
// do something with graphics[i]
}

even better


dojo.forEach(map.graphics.graphics, "console.log(item.getDojoShape().rawNode.style.display)");
//or
dojo.forEach(map.graphics.graphics, "console.log(item,index,array)");
//or
dojo.forEach(map.graphics.graphics, function(item){//item is a graphic element });

Note: @version 1.4 you will have ability to add multiple graphics layers (in addition to the default graphics layer) and can control the stack order (z-index).

Advertisements

Ready to use Sample layouts using Dojo

Just posted a blog entry on the ArcGIS Server Blog. Check it out.

Blog talks about how to use Dojo Dijits – BorderContainer (dijit.layout.BorderContainer) and ContentPane (dijit.layout.ContentPane) to design your layouts for application. I have created a bunch of sample layouts with most of the commonly used layouts, check out the links below.

You an try the live sample at: http://serverapps.esri.com/templates/index.html

You can download the samples at: Resource Center Code Gallery

Good Javascript and Dojo Resources

Here is a list of Javascript and Dojo learning resources (thanks Grayson) that I use. If you know of any good links, add in a comment and I will update the post.

Javascript

Essential Javascript – A Javascript Tutorial

http://www.comptechdoc.org/independent/web/cgi/javamanual/

http://www.w3schools.com/jsref/default.asp

http://javascript.crockford.com/

Dojo

http://dojotoolkit.org/key-links

Dojo Feature Explorer

http://www.sitepen.com/labs/dojo.php

http://archive.dojotoolkit.org/nightly/checkout/ (Great source for learning how to use dijits and dojox widgets, check out the tests folder)

http://www.roseindia.net/dojo/

10 helpings of Dojo goodness

Minify JavaScript and CSS files in IDE – netbeans and eclipse

This post talks about how to go about minifying the javascript and css files directly from your IDE (Eclipse and Netbeans) using the YUICompressor and YUIAnt jar files.

Before we look into more specifics you will have to download these two:
1. YUICompression jar from the Yahoo developer site, here are the links : More InfoDownload
2. YUIAnt jar file from this link
Read the rest of this entry »

Deploying Java Web ADF application on Jetty

Recently I installed and successfully deployed a ESRI ArcGIS Server based Java Web Mapping application on Jetty 6.1.14

Though Jetty is not officially supported deployment container, since its standards based it works without any issues.

For starters, if you are new to Jetty or if you are looking for an alternative to Tomcat find out more on Jetty at http://www.mortbay.org/jetty/
Read the rest of this entry »

Minify the Javascript libraries and CSS files

In this post I show you how to minify JavaScript and CSS files which is very useful for improving web application performance. In my recent post РMeasuring Web Mapping Application Performance using YSlow Рpart 2 I talked about minifying the JavaScript and CSS files used in the web mapping application but really dint discuss how to go about doing this.

Before we go further lets understand what do we mean my “minify” – By definition minify is to make it smaller. So in terms of JavaScript and CSS files, we can make the files smaller by removing the white spaces created by tab or space or new line and by removing any comments in the files and thus reducing the file size and improving download speed and response time. Read the rest of this entry »

Rename ArcGIS Server Hostname

Note: This post is for ArcGIS Server 9.2 Java (any platform)

Did you ever install ArcGIS Server Java first and then go ahead and change the host name of the machine only to realize now the you will have to either re-install or run post install or contact support to fix ArcGIS Server.

Did you ever have an disk image with ArcGIS Server Java installed and configured, then you go ahead and ghost the image on many machines only to realize that all the hostnames are the same.

Don’t worry, In this post you will find information on what files has got the entries of the host name and for what purpose. This will also give you a good understanding of how ArcGIS Server Manager and Web Services Handler uses these configuration files.

Read the rest of this entry »