ArcGIS Online

Working with the Popup Widget in the ArcGIS Server API for JavaScript

Posted on June 13, 2011. Filed under: ArcGIS Online, ArcGIS Server, GeoSpatial Training Services, JavaScript |

The new Popup widget, provided with the 2.3 release of the ArcGIS Server API for JavaScript can be used as a replacement for the default info window.  This new widget provides an attractive alternative to the info window complete with navigation tools that allow you to move through the selected features, zoom to a selected feature, highlight the selected feature, and maximize/minimize,close the window.

You can also customize the look of the window as well as the content.  In this post you will learn how easy it is to programmatically add this new widget to your application.  You can also use the ArcGIS.com map viewer to create popup windows.  This post is the first in a three part series.  This first post will cover the basics of adding a Popup window to your application while the second and third posts will cover advanced customization topics.

For this series of posts we’ll review several Popup samples which can be found here, here, here, and here.

Reference the Widget
You’ll first want to add the popup stylesheet to your application as seen below:

Next, reference the Popup widget using dojo.require.

Creating the Popup
The constructor for a Popup widget takes two parameters: options and an HTML source reference to where the popup will be placed.  The ‘options’ parameter is optional and can be used to customize the look of the popup window.

In the code example below you’ll see that we simply provide a ‘null’ reference for the options object.  This simply means that we’ll use the default options provided by the Popup.  The srcNodeRef is going to be a <div> container that we create to hold the content.

The second line of code highlighted below indicates that when the map is initially created the new Popup widget, stored in a variable called ‘popup’, will serve as the info window for the application.

Finally, the dojo.place method is used to define where the popup will appear which in this case is the <div> container that we created.  Place the popup under the map’s root element. This ensures that the coordinate space used by the popup for positioning aligns with the map’s coordinate space.

Adding just the lines we’ve already discussed is enough to create a basic Popup window.  Many times that’s all you need for your application, but you can also customize not only the look of the window but also the content.

Formatting with the PopupTemplate Class
Popup content can be formatted using the PopupTemplate class.  PopupTemplate inherits from the InfoTemplate class.  A code example showing how to create an instance of PopupTemplate is provided below.  This object can be used to create a title and description for the window along with a means for defining the fields that should be visible along with their labels and formatting.  You can also define whether attachments should be visible (showAttachments:<boolean>) as well as images, charts, and other media that will be part of the window.  We’ll examine some of these advanced customization techniques in our second post.

In this code example above we’ve simply defined a title for the window along with the fields that will be visible and stated that we want attachments to be loaded if they exist.

A PopupTemplate is then referenced from the ‘infoTemplate’ option when defining a new FeatureLayer as seen in the code example below.

In the next post we’ll examine several ways that you can customize the look and content of your popup windows.

Want to learn more about creating ArcGIS Server applications with the JavaScript API?  The next session of our Internet based, instructor guided course Mastering the ArcGIS Server JavaScript API begins August 29th and runs through September 30th.

Read Full Post | Make a Comment ( None so far )

ArcGIS Online Maps Migrated to Google Maps/Bing Maps Tiling Scheme

Posted on January 21, 2010. Filed under: ArcGIS Online, ESRI, Google Maps, Virtual Earth |

Good news!  Looks like ESRI has finished the migration of ArcGIS Online Maps to a Google Maps/Bing Maps tiling scheme.  According to ESRI:

ArcGIS Online map services have been migrated to the Google Maps/Bing Maps tiling scheme in Web Mercator Auxiliary Sphere. This enables Web developers to more easily combine ArcGIS Online map services with other popular Web map services including those from Bing Maps, Google Maps, and other providers using the same Web map tiling scheme.

The existing services in the ArcGIS Online tiling scheme will remain available for at least the next six months and, depending on demand, may remain available longer. Although the services will remain available, the content will no longer be updated.

For more details, see Migrating map tiling schemes in the ArcGIS Online Help.

Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...