Embedding Links and Images - AppGeo/GPV GitHub Wiki
Links and images can be shown in data tabs and the identify popup window by embedding text with a wiki-like syntax into the data values returned by the [data tab](Data Tab Stored Procedure) and [identify](Identify Stored Procedure) stored procedures. The column values must begin and end with square brackets and must have one of the following structures:
Text Link
[<link url> <link text>]
Thumbnail image link
[<link url> <thumbnail image url>]
Use this when you have a small thumbnail image that will fit in the display area.
Scaled image link
[<link url> <scaled image url> <scaled image width>]
Use this when the image is large and must be scaled down to fit into the display area. ''link url'' and ''scaled image url'' can point to the same image.
When using a thumbnail image or scaled image the image URL must end with one of these extensions: .JPG, .GIF, or .PNG. If necessary, you can add a fake parameter onto your URL with this extension (e.g. "?ext=.jpg").
Open a named browser window
[<link url> {name} <link text>]
[<link url> {name} <thumbnail image url>]
[<link url> {name} <scaled image url> <scaled image width>]
Optionally you can include the name of the browser window to open in braces after the link URL. This name can be one of the built-in names used by the JavaScript window.open command ("_blank" for a new window, "_self" for the current window) or your own custom window name.
The link URL can point to external resources using the ''http'', ''https'', ''ftp'' or ''mailto'' protocols. In [data tabs](Data Tab Stored Procedure) it also supports a special ''application'' protocol for internally resetting the GPV based on URL parameters. For instance, the following link URL changes the target layer and selects features in that new layer:
application:targetlayer=Parcels&targetids=30-49-1,30-49-2
The ''application'' protocol supports the following URL parameters only:
- layerson
- layersoff
- targetlayer
- targetids
- targetparams
- proximity
- selectionlayer
- selectionids
- activemapid
- activedataid
- query
- datatab
- scaleby
Example This [data tab](Data Tab Stored Procedure) stored procedure returns a text link to a deed document and a scaled image link to a house photo.
SQL Server
create procedure GPVDataTab_ParcelBasic
@id nvarchar(26)
as
select prop_street as Address,
prop_city as City,
'[http://host/DeedImages/' + book_page + '.gif Click here]' as Deed,
'[http://host/HouseImages/' + parcel_id + '.jpg http://host/HouseImages/' + parcel_id + '.jpg 150]' as Photo
from parcel_base
where parcel_id = @id
go
Oracle
create or replace package GPVPackage as
type t_cursor is ref cursor;
procedure GPVDataTab_ParcelBasic(id in nvarchar2, io_cursor out t_cursor);
end GPVPackage;
create or replace package body GPVPackage as
procedure GPVDataTab_ParcelBasic(id in nvarchar2, io_cursor out t_cursor) is
begin
open io_cursor for select prop_street as "Address",
prop_city as "City",
'[http://host/DeedImages/' || book_page || '.gif Click here]' as "Deed",
'[http://host/HouseImages/' || parcel_id || '.jpg http://host/HouseImages/' || parcel_id || '.jpg 150]' as "Photo"
from parcel_base
where parcel_id = id;
end GPVDataTab_ParcelBasic;
end GPVPackage;
by Xia Jin, GIS Manager, Town of Mansfield
Internet Explorer or Firefox cannot render TIFF images without a proper plug-in. Since we have thousands of scanned documents in TIFF format, and many more documents are going to be scanned, I found that it is time-consuming to convert all TIFF images to other formats such as JPEG, PNG, and GIF beforehand.
There are two resolutions.
1. Convert TIFF to JPEG on the fly
Note: you can easily convert TIFF to other formats such as PNG and GIF by simply changing the code in step 2.
Step 1. create a file named Tiff2Jpeg.aspx
Step 2. copy the following code into the file.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script language="VB" runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim objBitmap As New Bitmap(Request.MapPath(Request("tiff")))
Response.ContentType = "image/jpeg"
objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg)
Response.End()
End Sub
</script>
Step 3. save this file in GPV folder (\hosted\GPV).
Step 4. to use this file as a translator, make some change the text link for embedded images from something like
"YourTiffImageFileName.tif"
to
"Tiff2Jpeg.aspx?tiff=YourTiffImageFileName.tif"
Note: pay extra attention to make sure the file path is correct.
Example
The path to the GPV folder is \hosted\GPV and the path to the folder with TIFF images is \hosted\IMAGES\Sewer\SewerTieCards
This will work for a JPEG.
'[http://mysite.com/IMAGES/Sewer/SewerTieCards/'+ GIS_ID +'.jpg View]' as [Sewer Tie]
This will convert a TIFF to JPEF on the fly.
'[http://mysite.com/GPV/Tiff2Jpeg.aspx?tiff=/IMAGES/Sewer/SewerTieCards/'+ GIS_ID +'.tif View]' as [Sewer Tie]
2. Force TIFF images to be downloaded instead of being opened in a new window
Step 1. create a file named TiffDownload.aspx
Step 2. copy the following code into the file.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script language="VB" runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim tiffPathName As String = Request.MapPath(Request("tiff"))
Dim fileName = System.IO.Path.GetFileName(tiffPathName)
Response.ContentType = "image/tiff"
Response.AppendHeader("content-disposition", "attachment; filename=" + fileName)
Response.WriteFile(tiffPathName)
Response.End()
End Sub
</script>
Step 3. save this file in the GPV folder (\hosted\GPV).
Step 4. To use this file to enforce download, make some change to the text link for embedded images from something like
"YourTiffImageFileName.tif"
to
"TiffDownload.aspx?tiff=YourTiffImageFileName.tif"
Note: pay extra attention to make sure the file path is correct.
Example
The path to the GPV folder is \hosted\GPV and the path to the folder with tiff images is \hosted\IMAGES\Sewer\SewerTieCards
This will work for a JPEG.
'[http://mysite.com/IMAGES/Sewer/SewerTieCards/'+ GIS_ID +'.jpg View]' as [Sewer Tie]
This will force a TIFF to be downloaded.
'[http://mysite.com/GPV/TiffDownload.aspx?tiff=/IMAGES/Sewer/SewerTieCards/'+ GIS_ID +'.tif Download]' as [Sewer Tie]