Map Tip Stored Procedure - AppGeo/GPV GitHub Wiki

This stored procedure provides the content for a tip that is shown when the mouse is hovered a feature on the map. This procedure is configured in the StoredProc column of GPVLayerFunction when Function is set to "maptip".

Raster layers are supported (ArcGIS for Server only).

Input

The first parameter receives a text string containing the map ID of a feature or a comma-separated list of raster values. The raster values will be in the same order as those provided by ArcMap's identify tool.

If provided, the optional second parameter receives the role of the current user.

Output

A single SQL result set containing one row and one or more columns of data. Each consecutive column containing a non-null value will generate a new line of map tip text. Data values will appear on the map tip exactly as the are provided in this result set, so format the data as necessary. Newline characters (ASCII 10) embedded in the data values will also force new lines of text on the map tip. Column names are ignored.

Basic Example

This procedure returns an address for the specified building ID as a map tip.

SQL Server

create procedure GPVMapTip_Building
  @gpin nvarchar(20)
as
select ltrim(convert(nvarchar, HouseNo) + ' ' + Street) as MapTip
  from addressing 
  where gpin = @gpin
go

Oracle

create or replace package GPVPackage as
  type t_cursor is ref cursor;
  procedure GPVMapTip_Building(ingpin in nvarchar2, io_cursor out t_cursor);
end GPVPackage;

create or replace package body GPVPackage as
  procedure GPVMapTip_Building(ingpin in nvarchar2, io_cursor out t_cursor) is
    begin
    open io_cursor for select ltrim(to_char(HouseNo) || ' ' || Street) as MapTip
      from addressing where gpin = ingpin;
    end GPVMapTip_Building;
end GPVPackage;

Raster Example (SQL Server)

In this example two raster values are returned from ArcGIS for Server, an ID and an elevation, separated by a comma. We'll ignore the ID and extract the text after the comma, convert it to a number, round to whole units, and embed in a text string.

create procedure GPVMapTip_ElevationModel
  @rasterValues nvarchar(20)
as
  select 'Elevation: ' + 
    CONVERT(nvarchar, ROUND(CONVERT(float, SUBSTRING(@rasterValues, 
    CHARINDEX(',', @rasterValues) + 1, 20)), 0)) + ' ft'

Note that you can return a value without actually querying a table.