clickable and now toggleable regions
This commit is contained in:
20
config.js
20
config.js
@@ -33,9 +33,25 @@ var signGroups = [
|
||||
{label: "All", match: function(s) {return true}},
|
||||
];
|
||||
|
||||
//piTODO: document this
|
||||
/* regionGroups -- A list of region groups. A region can fall into zero, one, or more than one
|
||||
* group. See below for some examples.
|
||||
* regions have been designed to work with the
|
||||
* WorldGuard Overviewer Region importer at https://github.com/pironic/WG2OvR But your host must support php in order
|
||||
* to run WG2OvR. You can also continue to use any other region format, but your regions
|
||||
* must now have a label definned in the regions.js.
|
||||
*
|
||||
* Required:
|
||||
* label : string. Displayed in the drop down menu control.
|
||||
* clickable : boolean. Will determine if we should generate an experimental info window
|
||||
* that shows details about the clicked region.
|
||||
* match : function. Applied to each region (from region.js). It returns true if the region
|
||||
* Should be part of the group.
|
||||
*
|
||||
* Optional:
|
||||
* checked : boolean. Set to true to have the group visible by default
|
||||
*/
|
||||
var regionGroups = [
|
||||
{label: "WorldGuard", match: function(s) {return true}},
|
||||
//{label: "WorldGuard", clickable: false, checked: false, match: function(s) {return true}},
|
||||
];
|
||||
|
||||
/* mapTypeData -- a list of alternate map renderings available. At least one rendering must be
|
||||
|
||||
@@ -219,20 +219,23 @@ function initRegions() {
|
||||
|
||||
// pull all the points out of the regions file.
|
||||
var converted = new google.maps.MVCArray();
|
||||
var infoPoint = "";
|
||||
for (j in region.path) {
|
||||
var point = region.path[j];
|
||||
converted.push(fromWorldToLatLng(point.x, point.y, point.z));
|
||||
|
||||
}
|
||||
|
||||
for (idx in regionGroups) {
|
||||
var regionGroup = regionGroups[idx];
|
||||
var testfunc = regionGroup.match;
|
||||
var clickable = regionGroup.clickable
|
||||
var label = regionGroup.label;
|
||||
|
||||
if (region.closed) {
|
||||
var shape = new google.maps.Polygon({
|
||||
name: region.label,
|
||||
clickable: false,
|
||||
clickable: clickable,
|
||||
geodesic: false,
|
||||
map: null,
|
||||
strokeColor: region.color,
|
||||
@@ -246,7 +249,7 @@ function initRegions() {
|
||||
} else {
|
||||
var shape = new google.maps.Polyline({
|
||||
name: region.label,
|
||||
clickable: false,
|
||||
clickable: clickable,
|
||||
geodesic: false,
|
||||
map: null,
|
||||
strokeColor: region.color,
|
||||
@@ -257,6 +260,23 @@ function initRegions() {
|
||||
});
|
||||
}
|
||||
regionCollection[label].push(shape);
|
||||
|
||||
if (clickable) {
|
||||
// add the region infowindow popup
|
||||
infowindow = new google.maps.InfoWindow();
|
||||
google.maps.event.addListener(shape, 'click', function(e,i) {
|
||||
|
||||
var contentString = "<b>Region: "+this.name+"</b><br />";
|
||||
contentString += "Clicked Location: <br />" + e.latLng.lat() + "," + e.latLng.lng() + "<br />";
|
||||
|
||||
// Replace our Info Window's content and position
|
||||
infowindow.setContent(contentString);
|
||||
infowindow.setPosition(e.latLng);
|
||||
|
||||
infowindow.open(map);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user