forked from CTLocalGovTeam/park-and-recreation-finder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printMap.htm
190 lines (171 loc) · 8.31 KB
/
printMap.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!doctype html>
<html lang="en">
<head>
<meta charset=utf-8>
<!--
| Version 10.2
| Copyright 2012 Esri
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
-->
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Park and Recreation Finder</title>
<link rel="shortcut icon" href="images/appIcon.ico" />
<link rel="apple-touch-icon" href="images/appIcon.png" />
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css" />
<link id="stylesheet" href='http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox/mobile/themes/iPhone/iPhone.css'
rel='stylesheet' />
<link href="styles/parksAndRecreationFinder.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
djConfig = (function () {
var base = location.href.split("/");
base.pop();
base = base.join("/");
return {
async: false,
mblHideAddressBar: false,
packages: [{
name: "js",
location: base + "/js"
}]
};
})();
</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5compact">
</script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("esri.layers.FeatureLayer");
dojo.require("esri.tasks.geometry");
var window_opener = window.opener;
var tempPushPinLayer = 'tempPushPinLayer';
var tempBuffer = 'tempBuffer';
var tempRouteLayer = 'tempRouteLayer';
var tempHighlightedLayer = 'tempHighlightedLayer';
var printmap;
var routeLayer;
var initialExtent;
var graphicsLayer;
var directions;
var directionsHeader;
var highlightedLayer;
var symbol;
function Init() {
graphicsLayer = window_opener.GetGraphicsLayer();
routeLayer = window_opener.GetRouteLayer();
directions = window_opener.drivingDirections;
directionsHeader = window_opener.GetDirectionsHeader();
highlightedLayer = window_opener.GetHighlightedPollLayer();
printmap = new esri.Map("mapPrint", { slider: false });
/*Code for adding basemap layers to print*/
var layerUrl = window_opener.GetLayerUrl();
var baseMapLayer = new esri.layers.ArcGISTiledMapServiceLayer(layerUrl);
printmap.addLayer(baseMapLayer);
/*Code for getting feature layer*/
parksLayer = window_opener.GetParksLayer();
var parksFeatureLayer = new esri.layers.FeatureLayer(parksLayer, {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"]
});
printmap.addLayer(parksFeatureLayer);
dojo.connect(parksFeatureLayer, "onUpdateEnd", MapRenderComplete);
dojo.connect(printmap, "onLoad", function () {
printmap.disablePan();
printmap.disableDoubleClickZoom();
printmap.disableKeyboardNavigation();
printmap.disableScrollWheelZoom();
printmap.disableMapNavigation();
var extent = null;
var gLayer = new esri.layers.GraphicsLayer();
gLayer.id = tempRouteLayer;
printmap.addLayer(gLayer);
var symbol;
for (var i = 0; i < routeLayer.graphics.length; i++) {
symbol = new esri.symbol.SimpleLineSymbol().setColor(routeLayer.graphics[i].symbol.color).setWidth(routeLayer.graphics[i].symbol.width);
var polyLine = new esri.geometry.Polyline(routeLayer.graphics[i].geometry.toJson());
AddGraphic(gLayer, symbol, polyLine);
if (extent) {
extent = extent.union(polyLine.getExtent());
}
else {
extent = polyLine.getExtent();
}
}
printmap.setExtent(extent.expand(2));
var gLayer = new esri.layers.GraphicsLayer();
gLayer.id = tempPushPinLayer;
printmap.addLayer(gLayer);
for (var k = 0; k < graphicsLayer.graphics.length; k++) {
var mapPoint = new esri.geometry.Point(graphicsLayer.graphics[k].geometry.x, graphicsLayer.graphics[k].geometry.y, printmap.spatialReference);
symbol = new esri.symbol.PictureMarkerSymbol(graphicsLayer.graphics[k].symbol.url, 25, 25);
AddGraphic(gLayer, symbol, mapPoint);
}
var gLayer = new esri.layers.GraphicsLayer();
gLayer.id = tempHighlightedLayer;
printmap.addLayer(gLayer);
for (var j = 0; j < highlightedLayer.graphics.length; j++) {
var mapPoint = new esri.geometry.Point(highlightedLayer.graphics[j].geometry.x, highlightedLayer.graphics[j].geometry.y, printmap.spatialReference);
symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, highlightedLayer.graphics[j].symbol.size, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color(highlightedLayer.graphics[j].symbol.outline.color), 4), new dojo.Color([0, 0, 0, 0]));
AddGraphic(gLayer, symbol, mapPoint);
}
dojo.byId("tdParkName").innerHTML = window_opener.document.getElementById("spanDirectionHeader").getAttribute("parkName");
RemoveChildren(dojo.byId("tblDirections"));
var tbody = dojo.create("tbody", {}, dojo.byId("tblDirections"));
var trHeader = dojo.create("tr", {}, tbody);
trHeader.style.height = "30px";
for (var i = 0; i < directionsHeader.length; i++) {
var tdHeader = dojo.create("td", {}, trHeader);
if (i == 1) {
tdHeader.align = "right";
}
tdHeader.innerHTML = directionsHeader[i];
}
for (var i in directions) {
var tr = dojo.create("tr", {}, tbody);
tr.style.height = "30px";
if (i % 2 == 0) {
tr.style.backgroundColor = "gray";
}
var td = dojo.create("td", {}, tr);
td.align = "left";
var tdMiles = dojo.create("td", {}, tr);
tdMiles.align = "right";
td.innerHTML = (Number(i) + 1) + ". " + directions[i].text;
tdMiles.innerHTML = (directions[i].distance) ? directions[i].distance : "";
}
});
}
function MapRenderComplete() {
setTimeout(function () {
window.print();
}, 500);
}
dojo.addOnLoad(Init);
</script>
</head>
<body class="claro" style="font-size: 11px; font-family: Verdana; overflow-y: auto;margin-left:5px;">
<div style="width: 670px; height: 50px;">
<table align="center" style="width: 100%; height: 100%">
<tr>
<td id="tdParkName" align="center" style="font-weight: bold; font-size: 15px;color:Black;">
</td>
</tr>
</table>
</div>
<div id="mapPrint" style="position: relative; width: 665px; height: 450px; border: 1px solid #000;">
</div>
<table id="tblDirections" style="width: 665px; border: 1px solid #000; color: Black;">
</table>
</body>
</html>