-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_script.php
154 lines (134 loc) · 5.3 KB
/
map_script.php
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
<?php
/////////////////////////////////////////////////////////////////////////////////
//
// Modified from OpenSim WebInterface Redux v0.28
// by Fumi.Iseki
//
//
// $size, $centerX, $centerY, $world_map_url, ENV_HELPER_PATH, $course_id are needed
//
//
if (!defined('ENV_READ_CONFIG')) require_once(realpath(dirname(__FILE__).'/../include/config.php'));
if (!defined('ENV_READ_DEFINE')) require_once(realpath(ENV_HELPER_PATH.'/../include/env_define.php'));
require_once(realpath(ENV_HELPER_PATH.'/../include/opensim.mysql.php'));
//
$display_marker = 'dr'; // infomation marker
if ($size==4){
$minuszoom = 0; $pluszoom = 8; $infosize = 2;
}
else if ($size==8){
$minuszoom = 4; $pluszoom = 16; $infosize = 4;
}
else if ($size==16){
$minuszoom = 8; $pluszoom = 32; $infosize = 8;
}
else if ($size==32){
$minuszoom = 16; $pluszoom = 64; $infosize = 10;
}
else if ($size==64){
$minuszoom = 32; $pluszoom = 128; $infosize = 12;
}
else if ($size==128) {
$minuszoom = 64; $pluszoom = 256; $infosize = 20;
}
else if ($size==256) {
$minuszoom = 128; $pluszoom = 512; $infosize = 40;
}
else if ($size==512) {
$minuszoom = 256; $pluszoom = 0; $infosize = 60;
}
?>
function regionwin(uuid) {
window.open("<?php echo ENV_HELPER_URL.'/sim.php?course='.$course_id.'®ion='?>"+uuid, '',
'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=800,height=450');
}
function loadmap() {
ZoomSize(<?php echo $size?>);
mapInstance = new WORLDMap(document.getElementById('map-container'), {hasZoomControls: false, hasPanningControls: true});
mapInstance.centerAndZoomAtWORLDCoord(new XYPoint(<?php echo $centerX?>, <?php echo $centerY?>), 1);
<?php
$infos = opensim_get_regions_infos();
foreach($infos as $info)
{
$regionName = $info['regionName'];
$serverURI = $info['serverURI'];
$serverIP = $info['serverIP'];
$serverPort = $info['serverPort'];
$locX = $info['locX'];
$locY = $info['locY'];
$sizeX = $info['sizeX'];
$sizeY = $info['sizeY'];
$uuid = $info['UUID'];
$estateName = $info['estate_name'];
$ownerName = $info['est_fullname'];
if (!$ownerName) $ownerName = $info['rgn_fullname'];
$dx = 0.00; $dy = 0.00;
if ($display_marker=='tl') {
$dx = -0.40; $dy = 0.40;
}
else if ($display_marker=='tr') {
$dx = 0.40; $dy = 0.40;
}
else if ($display_marker=='dl') {
$dx = -0.40; $dy = -0.40;
}
else if ($display_marker=='dr') {
$dx = 0.40; $dy = -0.40;
}
$rgnX = $size*($sizeX/256);
$rgnY = $size*($sizeY/256);
$locX = $locX/256;
$locY = $locY/256;
$crdX = $locX + ($sizeX/256-1)*0.5;
$crdY = $locY + ($sizeY/256-1)*0.5;
$mrkcrdX = $crdX + $dx*($sizeX/256);
$mrkcrdY = $crdY + $dy*($sizeY/256);
$hsize = 2048/$size;
$wsize = 4096/$size;
if ($locX<$centerX+$wsize && $locX>$centerX-$wsize && $locY<$centerY+$hsize && $locY>$centerY-$hsize) {
$server = '';
if ($serverURI!='') {
$dec = explode(':', $serverURI);
if (!strncasecmp($dec[0], 'http', 4)) $server = $dec[0].':'.$dec[1];
}
if ($server=='') {
$server = 'http://'.$serverIP;
}
$server = $server.':'.$serverPort;
//
$imageuuid = str_replace('-', '', $uuid);
$imageURL = $server.'/index.php?method=regionImage'.$imageuuid;
if ($isGuest) {
$windowHTML = '<strong>Name: </strong><strong style=\"color:#0055cc;\">'.$regionName.'</strong><br /><br />';
}
else {
$windowHTML = '<strong>Name: </strong><a style=\"cursor:pointer;\" onClick=\"regionwin(\''.$uuid.'\')\"><strong style=\"color:#0055cc;\"><u>'.$regionName.'</u></strong></a><br /><br />';
}
/*if ($hasPermit) {
$windowHTML.= 'UUID: <strong>'.$uuid.'</strong><br /><br />';
$windowHTML.= 'IP address: <strong>'.$serverIP.'</strong><br /><br />';
}*/
$windowHTML.= '<strong>Coordinates : </strong><strong style=\"color: #115500\">'.$locX.', '.$locY.'</strong><br /><br />';
$windowHTML.= '<strong>Estate Name : </strong><strong style=\"color: #882222\">'.$estateName.'</strong><br /><br />';
$windowHTML.= '<strong>Admin Name : </strong><strong style=\"color: #000055\">'.$ownerName.'</strong><br />';
?>
var tmp_region_image = new Img("<?php echo $imageURL?>", <?php echo $rgnX?>, <?php echo $rgnY?>);
var region_loc = new Icon(tmp_region_image);
var all_images = [region_loc, region_loc, region_loc, region_loc, region_loc, region_loc];
var marker = new Marker(all_images, new XYPoint(<?php echo $crdX?>, <?php echo $crdY?>));
mapInstance.addMarker(marker);
var map_marker_img = new Img("images/info.gif", <?php echo $infosize?>, <?php echo $infosize?>);
var map_marker_icon = new Icon(map_marker_img);
var mapWindow = new MapWindow("<?php echo $windowHTML?>", {closeOnMove: true});
var all_images = [map_marker_icon, map_marker_icon, map_marker_icon, map_marker_icon, map_marker_icon, map_marker_icon];
var marker = new Marker(all_images, new XYPoint(<?php echo $mrkcrdX?>, <?php echo $mrkcrdY?>));
mapInstance.addMarker(marker, mapWindow);
<?php
}
}
?>
}
function setZoom(size) {
var cord = mapInstance.getMapCenter();
window.location.href = "<?php echo $world_map_url?>?size="+size+"&ctX="+cord.x+"&ctY="+cord.y+"";
}