2011-07-27 06:07:20 +02:00
|
|
|
regionConstructors['polygon'] = function(map, resname, region)
|
2011-04-14 02:58:25 +02:00
|
|
|
{
|
2011-07-27 06:07:20 +02:00
|
|
|
$.each(region.Areas, function(aname, area) {
|
|
|
|
var name = resname + '_' + aname;
|
2011-04-14 02:58:25 +02:00
|
|
|
if(regionCfg.use3dregions)
|
|
|
|
{
|
|
|
|
regionPolygons[name+'_bottom'] = new google.maps.Polygon($.extend(regionCfg.regionstyle, {
|
|
|
|
paths: [
|
2011-07-27 06:07:20 +02:00
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y1,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y1,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y1,area.Z2),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y1,area.Z2)
|
2011-04-14 02:58:25 +02:00
|
|
|
],
|
|
|
|
map: map
|
|
|
|
}));
|
|
|
|
google.maps.event.addListener(regionPolygons[name+'_bottom'] , 'click', function(event) {
|
2011-07-27 06:07:20 +02:00
|
|
|
regionInfo(event, resname, region);
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
regionPolygons[name+'_top'] = new google.maps.Polygon($.extend(regionCfg.regionstyle, {
|
|
|
|
paths: [
|
2011-07-27 06:07:20 +02:00
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y2,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y2,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y2,area.Z2),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y2,area.Z2)
|
2011-04-14 02:58:25 +02:00
|
|
|
],
|
|
|
|
map: map
|
|
|
|
}));
|
|
|
|
google.maps.event.addListener(regionPolygons[name+'_top'] , 'click', function(event) {
|
2011-07-27 06:07:20 +02:00
|
|
|
regionInfo(event, resname, region);
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
regionPolygons[name+'_east'] = new google.maps.Polygon($.extend(regionCfg.regionstyle, {
|
|
|
|
paths: [
|
2011-07-27 06:07:20 +02:00
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y1,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y2,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y2,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y1,area.Z1)
|
2011-04-14 02:58:25 +02:00
|
|
|
],
|
|
|
|
map: map
|
|
|
|
}));
|
|
|
|
google.maps.event.addListener(regionPolygons[name+'_east'] , 'click', function(event) {
|
2011-07-27 06:07:20 +02:00
|
|
|
regionInfo(event, resname, region);
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
regionPolygons[name+'_south'] = new google.maps.Polygon($.extend(regionCfg.regionstyle, {
|
|
|
|
paths: [
|
2011-07-27 06:07:20 +02:00
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y1,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y2,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y2,area.Z2),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y1,area.Z2)
|
2011-04-14 02:58:25 +02:00
|
|
|
],
|
|
|
|
map: map
|
|
|
|
}));
|
|
|
|
google.maps.event.addListener(regionPolygons[name+'_south'] , 'click', function(event) {
|
2011-07-27 06:07:20 +02:00
|
|
|
regionInfo(event, resname, region);
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
regionPolygons[name+'_west'] = new google.maps.Polygon($.extend(regionCfg.regionstyle, {
|
|
|
|
paths: [
|
2011-07-27 06:07:20 +02:00
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y1,area.Z2),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y2,area.Z2),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y2,area.Z2),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,area.Y1,area.Z2)
|
2011-04-14 02:58:25 +02:00
|
|
|
],
|
|
|
|
map: map
|
|
|
|
}));
|
|
|
|
google.maps.event.addListener(regionPolygons[name+'_west'] , 'click', function(event) {
|
2011-07-27 06:07:20 +02:00
|
|
|
regionInfo(event, resname, region);
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
regionPolygons[name+'_north'] = new google.maps.Polygon($.extend(regionCfg.regionstyle, {
|
|
|
|
paths: [
|
2011-07-27 06:07:20 +02:00
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y1,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y2,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y2,area.Z2),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,area.Y1,area.Z2)
|
2011-04-14 02:58:25 +02:00
|
|
|
],
|
|
|
|
map: map
|
|
|
|
}));
|
|
|
|
google.maps.event.addListener(regionPolygons[name+'_west'] , 'click', function(event) {
|
2011-07-27 06:07:20 +02:00
|
|
|
regionInfo(event, resname, region);
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-27 06:07:20 +02:00
|
|
|
middleY = area.Y2;
|
2011-04-14 02:58:25 +02:00
|
|
|
regionPolygons[name+'_bottom'] = new google.maps.Polygon($.extend(regionCfg.regionstyle, {
|
|
|
|
paths: [
|
2011-07-27 06:07:20 +02:00
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,middleY,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,middleY,area.Z1),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X2,middleY,area.Z2),
|
|
|
|
map.getProjection().fromWorldToLatLng(area.X1,middleY,area.Z2)
|
2011-04-14 02:58:25 +02:00
|
|
|
],
|
|
|
|
map: map
|
|
|
|
}));
|
|
|
|
google.maps.event.addListener(regionPolygons[name+'_bottom'] , 'click', function(event) {
|
2011-07-27 06:07:20 +02:00
|
|
|
regionInfo(event, resname, region);
|
2011-04-14 02:58:25 +02:00
|
|
|
});
|
|
|
|
}
|
2011-07-27 06:07:20 +02:00
|
|
|
});
|
2011-04-14 02:58:25 +02:00
|
|
|
}
|
|
|
|
regionConstructors['info'] = function(event, name, region)
|
|
|
|
{
|
2011-07-27 06:07:20 +02:00
|
|
|
var flags = "";
|
|
|
|
$.each(region.Permissions.AreaFlags, function(flag, status)
|
2011-04-14 02:58:25 +02:00
|
|
|
{
|
2011-07-27 06:07:20 +02:00
|
|
|
flags += flag+': '+status+'<br />';
|
|
|
|
});
|
|
|
|
var replace = ['%regionname%','%playerowners%','%flags%','%groupowners%', '%playermembers%', '%groupmembers%','%parent%', '%priority%'];
|
|
|
|
var by = [name,region.Permissions.Owner, flags, '', '', '', '', ''];
|
|
|
|
|
2011-04-14 02:58:25 +02:00
|
|
|
var contentString = arrayReplace(replace, by, regionCfg.infowindow)
|
|
|
|
|
|
|
|
regionInfoWindow.setContent(contentString);
|
|
|
|
regionInfoWindow.setPosition(event.latLng);
|
|
|
|
|
|
|
|
regionInfoWindow.open(dynmap.map);
|
|
|
|
}
|
|
|
|
regionConstructors['update'] = function(map)
|
|
|
|
{
|
|
|
|
if(regionInfoWindow)
|
|
|
|
regionInfoWindow.close();
|
|
|
|
$.each(regionPolygons, function(index, region)
|
|
|
|
{
|
|
|
|
region.setMap(null);
|
|
|
|
});
|
|
|
|
regionPolygons = {};
|
2011-07-27 06:07:20 +02:00
|
|
|
$.getJSON("standalone/res_" + map + ".json", function(data)
|
2011-04-14 02:58:25 +02:00
|
|
|
{
|
|
|
|
$.each(data, function(name, residence)
|
|
|
|
{
|
2011-07-27 06:07:20 +02:00
|
|
|
if(map == residence.Permissions.World)
|
2011-04-14 02:58:25 +02:00
|
|
|
makeRegionPolygonCube(dynmap.map, name, residence);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|