-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiMap.html
97 lines (89 loc) · 2.37 KB
/
multiMap.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Simple Map</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #FFF;
overflow: hidden;
font-family: "Trebuchet MS";
}
#map1Div ,#map2Div,#splitDiv{
float:left;
}
#splitDiv{
width:2px;
background:solid 2px green;
}
</style>
<script src="http://js.arcgis.com/3.13/"></script>
<script>
var map1,map2;
require(["esri/map", "dojo/_base/connect","dojo/_base/lang", "dojo/domReady!"], function(Map, connect,lang) {
map1 = new Map("map1Div", {
basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
center: [-122.45, 37.75], // longitude, latitude
zoom: 13
});
map2 = new Map("map2Div", {
basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
center: [-122.45, 37.75], // longitude, latitude
zoom: 13
});
map3 = new Map("map3Div", {
basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
center: [-122.45, 37.75], // longitude, latitude
zoom: 13
});
map4 = new Map("map4Div", {
basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
center: [-122.45, 37.75], // longitude, latitude
zoom: 13
});
var mapArray = [map1,map2,map3,map4];
connectMaps(mapArray);
function connectMaps(maps){
var panStatus = {source:maps[0],startMap:null};
for(var i=0;i<maps.length;i++){
var map1 = maps[i];
connect.connect(map1,"onMouseDragStart",lang.hitch(this,function(map){
panStatus.source = map;
}, map1));
connect.connect(map1,"onMouseOver",lang.hitch(this,function(map){
if(!panStatus.source._isPanningOrZooming()){
panStatus.source = map;
}
}, map1));
connect.connect(map1,"onExtentChange",lang.hitch(this,function(map){
sameExtent(map);
}, map1));
}
function sameExtent(mm){
for(var j=0;j<maps.length;j++){
var mapTarget = maps[j];
if(panStatus.source==mm&&mm!=mapTarget){
mapTarget.centerAndZoom(mm.extent.getCenter(),mm.getZoom());
}
}
}
}
});
</script>
</head>
<body>
<div id="map1Div"></div>
<div id="splitDiv"></div>
<div id="map2Div"></div>
<div id="map3Div"></div>
<div id="map4Div"></div>
</body>
</html>