- Mastering ArcGIS Server Development with JavaScript
- Ken Doman
- 206字
- 2021-07-16 20:03:04
InfoTemplates
InfoTemplates
, as we mentioned in Chapter 1, Your First Mapping Application, describe how you want to display data in a popup. The InfoTemplate
can be constructed using two strings, the title and the content. The title and content strings represent HTML templates, and you can substitute graphic attributes in the template. For a graphic's infoTemplate
, if you wanted to display the graphic's total attribute, you would insert the value in the template with a ${total}
, which shows the field name inserted inside the brackets of the substitution string ${}
.
If you want to display a popup containing all the name/value pairs in the graphic's attributes, you can use a wildcard ${*}
in the content value, as follows:
graphic.infoTemplate = new InfoTemplate("Attributes", "${*}");
For the content, you can add HTML content to the string, including tables, lists, images, and links. For example, you might use something like the following to describe a marine habitat:
graphic.infoTemplate = new InfoTemplate("Marine Habitat (${name})", "<table><tbody><tr><th>Type: </th><td>${type}</td></tr><tr><th>Ocean zone:</th><td>${zone}</td></tr><tr><td colspan='2'><img src='${imageSrc}' alt='${name}' /></td></tr></tbody></table>");
In the preceding example, we added the name attribute of the graphic to the title, and created a two-column table that displays the type of the graphic, the zone where the graphic resides, and a two-column wide image connected to the map graphic.
- 極簡(jiǎn)算法史:從數(shù)學(xué)到機(jī)器的故事
- Oracle從入門到精通(第3版)
- R語(yǔ)言數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南
- HTML5+CSS3網(wǎng)站設(shè)計(jì)教程
- Test-Driven Machine Learning
- Instant PHP Web Scraping
- Essential C++(中文版)
- PHP編程基礎(chǔ)與實(shí)踐教程
- Building Serverless Architectures
- 代碼閱讀
- Natural Language Processing with Python Quick Start Guide
- 軟件工程與UML案例解析(第三版)
- 深入理解Kafka:核心設(shè)計(jì)與實(shí)踐原理
- Kohana 3.0 Beginner's Guide
- Unity 5 Game Optimization