dynmap/web/js/regions_Residence.js

137 lines
4.9 KiB
JavaScript
Raw Normal View History

2011-07-27 06:07:20 +02:00
regionConstructors['polygon'] = function(map, resname, region)
{
2011-07-27 06:07:20 +02:00
$.each(region.Areas, function(aname, area) {
var name = resname + '_' + aname;
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)
],
map: map
}));
google.maps.event.addListener(regionPolygons[name+'_bottom'] , 'click', function(event) {
2011-07-27 06:07:20 +02:00
regionInfo(event, resname, region);
});
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)
],
map: map
}));
google.maps.event.addListener(regionPolygons[name+'_top'] , 'click', function(event) {
2011-07-27 06:07:20 +02:00
regionInfo(event, resname, region);
});
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)
],
map: map
}));
google.maps.event.addListener(regionPolygons[name+'_east'] , 'click', function(event) {
2011-07-27 06:07:20 +02:00
regionInfo(event, resname, region);
});
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)
],
map: map
}));
google.maps.event.addListener(regionPolygons[name+'_south'] , 'click', function(event) {
2011-07-27 06:07:20 +02:00
regionInfo(event, resname, region);
});
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)
],
map: map
}));
google.maps.event.addListener(regionPolygons[name+'_west'] , 'click', function(event) {
2011-07-27 06:07:20 +02:00
regionInfo(event, resname, region);
});
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)
],
map: map
}));
google.maps.event.addListener(regionPolygons[name+'_west'] , 'click', function(event) {
2011-07-27 06:07:20 +02:00
regionInfo(event, resname, region);
});
}
else
{
2011-07-27 06:07:20 +02:00
middleY = area.Y2;
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)
],
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-07-27 06:07:20 +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-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, '', '', '', '', ''];
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)
{
$.each(data, function(name, residence)
{
2011-07-27 06:07:20 +02:00
if(map == residence.Permissions.World)
makeRegionPolygonCube(dynmap.map, name, residence);
});
});
}