Compare commits

...

11 Commits

17 changed files with 247 additions and 43 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dynmap</groupId>
<artifactId>dynmap</artifactId>
<version>0.27</version>
<version>0.28</version>
<name>dynmap</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+20 -3
View File
@@ -34,7 +34,7 @@ public class Client {
public String channel;
public ChatMessage(String source, String channel, String playerName, String message, String playeraccount) {
this.source = source;
this.playerName = ChatColor.stripColor(playerName);
this.playerName = Client.stripColor(playerName);
this.message = ChatColor.stripColor(message);
this.account = playeraccount;
this.channel = channel;
@@ -58,7 +58,7 @@ public class Client {
public String playerName;
public String account;
public PlayerJoinMessage(String playerName, String playeraccount) {
this.playerName = ChatColor.stripColor(playerName);
this.playerName = Client.stripColor(playerName);
this.account = playeraccount;
}
@Override
@@ -80,7 +80,7 @@ public class Client {
public String playerName;
public String account;
public PlayerQuitMessage(String playerName, String playeraccount) {
this.playerName = ChatColor.stripColor(playerName);
this.playerName = Client.stripColor(playerName);
this.account = playeraccount;
}
@Override
@@ -142,4 +142,21 @@ public class Client {
public String type = "component";
/* Each subclass must provide 'ctype' string for component 'type' */
}
public static String stripColor(String s) {
s = ChatColor.stripColor(s); /* Strip standard color encoding */
/* Handle Essentials nickname encoding too */
int idx = 0;
while((idx = s.indexOf('&', idx)) >= 0) {
char c = s.charAt(idx+1); /* Get next character */
if(c == '&') { /* Another ampersand */
s = s.substring(0, idx) + s.substring(idx+1);
}
else {
s = s.substring(0, idx) + s.substring(idx+2);
}
idx++;
}
return s;
}
}
@@ -51,7 +51,7 @@ public class ClientUpdateComponent extends Component {
boolean hide = false;
s(jp, "type", "player");
s(jp, "name", ChatColor.stripColor(p.getDisplayName()));
s(jp, "name", Client.stripColor(p.getDisplayName()));
s(jp, "account", p.getName());
if(hideifshadow < 15) {
if(pl.getBlock().getLightLevel() <= hideifshadow)
@@ -100,7 +100,7 @@ public class ClientUpdateComponent extends Component {
for(Player p : hidden) {
JSONObject jp = new JSONObject();
s(jp, "type", "player");
s(jp, "name", ChatColor.stripColor(p.getDisplayName()));
s(jp, "name", Client.stripColor(p.getDisplayName()));
s(jp, "account", p.getName());
s(jp, "world", "-hidden-player-");
s(jp, "x", 0.0);
@@ -21,6 +21,8 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.CustomEventListener;
import org.bukkit.event.Event;
@@ -1073,6 +1075,61 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
}
}
/*
* Add in any missing sections to existing file, using resource
*/
public boolean updateUsingDefaultResource(String resourcename, File deffile, String basenode) {
InputStream in = getClass().getResourceAsStream(resourcename);
if(in == null) {
Log.severe("Unable to find resource - " + resourcename);
return false;
}
if(deffile.canRead() == false) { /* Doesn't exist? */
return createDefaultFileFromResource(resourcename, deffile);
}
/* Load default from resource */
YamlConfiguration def_fc = YamlConfiguration.loadConfiguration(in);
/* Load existing from file */
YamlConfiguration fc = YamlConfiguration.loadConfiguration(deffile);
/* Now, get the list associated with the base node default */
List<Map<String,Object>> existing = fc.getMapList(basenode);
Set<String> existing_names = new HashSet<String>();
/* Make map, indexed by 'name' in map */
if(existing != null) {
for(Map<String,Object> m : existing) {
Object name = m.get("name");
if(name instanceof String)
existing_names.add((String)name);
}
}
boolean did_update = false;
/* Now, loop through defaults, and see if any are missing */
List<Map<String,Object>> defmaps = def_fc.getMapList(basenode);
if(defmaps != null) {
for(Map<String,Object> m : defmaps) {
Object name = m.get("name");
if(name instanceof String) {
/* If not an existing one, need to add it */
if(existing_names.contains((String)name) == false) {
existing.add(m);
did_update = true;
}
}
}
}
/* If we did update, save existing */
if(did_update) {
try {
fc.set(basenode, existing);
fc.save(deffile);
} catch (IOException iox) {
Log.severe("Error saving migrated file - " + deffile.getPath());
return false;
}
Log.info("Updated file " + deffile.getPath());
}
return true;
}
private BlockListener ourBlockEventHandler = new BlockListener() {
+15 -7
View File
@@ -388,6 +388,7 @@ public class DynmapWorld {
int width = 128, height = 128;
BufferedImage zIm = null;
DynmapBufferedImage kzIm = null;
boolean blank = true;
int[] argb = new int[width*height];
int step = pd.stepsize << pd.zoomlevel;
int ztx = tx;
@@ -415,6 +416,7 @@ public class DynmapWorld {
if(im != null) {
im.getRGB(0, 0, width, height, argb, 0, width); /* Read data */
im.flush();
blank = false;
/* Do binlinear scale to 64x64 */
int off = 0;
for(int y = 0; y < height; y += 2) {
@@ -434,17 +436,15 @@ public class DynmapWorld {
/* blit scaled rendered tile onto zoom-out tile */
zIm.setRGB(((i>>1) != 0)?0:width/2, (i & 1) * height/2, width/2, height/2, argb, 0, width);
}
else if((pd.background != 0) && (pd.fmt != ImageFormat.FORMAT_PNG)) {
else {
Arrays.fill(argb, pd.background);
/* blit scaled rendered tile onto zoom-out tile */
zIm.setRGB(((i>>1) != 0)?0:width/2, (i & 1) * height/2, width/2, height/2, argb, 0, width);
}
}
else if((pd.background != 0) && (pd.fmt != ImageFormat.FORMAT_PNG)) {
else {
Arrays.fill(argb, pd.background);
/* blit scaled rendered tile onto zoom-out tile */
zIm.setRGB(((i>>1) != 0)?0:width/2, (i & 1) * height/2, width/2, height/2, argb, 0, width);
}
/* blit scaled rendered tile onto zoom-out tile */
zIm.setRGB(((i>>1) != 0)?0:width/2, (i & 1) * height/2, width/2, height/2, argb, 0, width);
}
FileLockManager.getWriteLock(zf);
try {
@@ -456,7 +456,15 @@ public class DynmapWorld {
int tilex = ztx/step/2;
int tiley = zty/step/2;
String key = world.getName()+".z"+pd.zoomprefix+pd.baseprefix;
if((!zf.exists()) || (crc != mm.hashman.getImageHashCode(key, null, tilex, tiley))) {
if(blank) {
if(zf.exists()) {
zf.delete();
hashman.updateHashCode(key, null, tilex, tiley, -1);
MapManager.mapman.pushUpdate(this.world, new Client.Tile(zfname));
enqueueZoomOutUpdate(zf, pd.zoomlevel+1);
}
}
else if((!zf.exists()) || (crc != mm.hashman.getImageHashCode(key, null, tilex, tiley))) {
try {
if(!zf.getParentFile().exists())
zf.getParentFile().mkdirs();
+4
View File
@@ -1076,6 +1076,10 @@ public class MapManager {
if(saverestorepending)
savePending();
if(sscache != null) {
sscache.cleanup();
sscache = null;
}
}
private HashMap<World, File> worldTileDirectories = new HashMap<World, File>();
@@ -84,6 +84,7 @@ public class MarkersComponent extends ClientComponent {
offlineset = api.createMarkerSet(OFFLINE_PLAYERS_SETID, configuration.getString("offlinelabel", "Offline"), null, true);
}
offlineset.setHideByDefault(configuration.getBoolean("offlinehidebydefault", true));
offlineset.setMinZoom(configuration.getInteger("offlineminzoom", 0));
offlineicon = api.getMarkerIcon(configuration.getString("offlineicon", "offlineuser"));
@@ -122,6 +122,10 @@ public class HDMap extends MapType {
if(c != null) {
bgcolornight = parseColor(c);
}
if(imgformat != ImageFormat.FORMAT_PNG) { /* If JPG, set background color opacity */
bgcolorday |= 0xFF000000;
bgcolornight |= 0xFF000000;
}
}
public HDShader getShader() { return shader; }
@@ -33,7 +33,7 @@ public class HDMapManager {
Log.verboseinfo("Loading shaders...");
File f = new File(plugin.getDataFolder(), "shaders.txt");
if(!plugin.createDefaultFileFromResource("/shaders.txt", f)) {
if(!plugin.updateUsingDefaultResource("/shaders.txt", f, "shaders")) {
return;
}
org.bukkit.util.config.Configuration bukkitShaderConfig = new org.bukkit.util.config.Configuration(f);
@@ -64,7 +64,7 @@ public class HDMapManager {
public void loadHDPerspectives(DynmapPlugin plugin) {
Log.verboseinfo("Loading perspectives...");
File f = new File(plugin.getDataFolder(), "perspectives.txt");
if(!plugin.createDefaultFileFromResource("/perspectives.txt", f)) {
if(!plugin.updateUsingDefaultResource("/perspectives.txt", f, "perspectives")) {
return;
}
org.bukkit.util.config.Configuration bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(f);
@@ -92,7 +92,7 @@ public class HDMapManager {
public void loadHDLightings(DynmapPlugin plugin) {
Log.verboseinfo("Loading lightings...");
File f = new File(plugin.getDataFolder(), "lightings.txt");
if(!plugin.createDefaultFileFromResource("/lightings.txt", f)) {
if(!plugin.updateUsingDefaultResource("/lightings.txt", f, "lightings")) {
return;
}
org.bukkit.util.config.Configuration bukkitLightingsConfig = new org.bukkit.util.config.Configuration(f);
@@ -1162,9 +1162,11 @@ public class TexturePack {
else {
clr = biomeLookup(li.argb, li.width, mapiter.getRawBiomeRainfall(), mapiter.getRawBiomeTemperature());
}
if(swamp_shaded && (mapiter.getBiome() == Biome.SWAMPLAND))
clr = (clr & 0xFF000000) | (((clr & 0x00FEFEFE) + 0x4E0E4E) / 2);
rslt.blendColor(clr);
if((clr & 0xFF000000) != 0) {
if(swamp_shaded && (mapiter.getBiome() == Biome.SWAMPLAND))
clr = (clr & 0xFF000000) | (((clr & 0x00FEFEFE) + 0x4E0E4E) / 2);
rslt.blendColor(clr);
}
}
}
@@ -178,9 +178,13 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
public String msg;
public String id;
public String label;
public int layerprio;
public int minzoom;
public MarkerSetUpdated(MarkerSet markerset, boolean deleted) {
this.id = markerset.getMarkerSetID();
this.label = markerset.getMarkerSetLabel();
this.layerprio = markerset.getLayerPriority();
this.minzoom = markerset.getMinZoom();
if(deleted)
msg = "setdeleted";
else
@@ -642,6 +646,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
private static final String ARG_ICON = "icon";
private static final String ARG_SET = "set";
private static final String ARG_PRIO = "prio";
private static final String ARG_MINZOOM = "minzoom";
private static final String ARG_STROKEWEIGHT = "weight";
private static final String ARG_STROKECOLOR = "color";
private static final String ARG_STROKEOPACITY = "opacity";
@@ -712,7 +717,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
public static boolean onCommand(DynmapPlugin plugin, CommandSender sender, Command cmd, String commandLabel, String[] args) {
String id, setid, file, label, newlabel, iconid, prio;
String id, setid, file, label, newlabel, iconid, prio, minzoom;
String val;
if(api == null) {
@@ -961,6 +966,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
id = parms.get(ARG_ID);
label = parms.get(ARG_LABEL);
prio = parms.get(ARG_PRIO);
minzoom = parms.get(ARG_MINZOOM);
if((id == null) && (label == null)) {
sender.sendMessage("<label> or id:<marker-id> required");
return true;
@@ -991,6 +997,13 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
sender.sendMessage("Invalid priority: " + prio);
}
}
if(minzoom != null) {
try {
set.setMinZoom(Integer.valueOf(minzoom));
} catch (NumberFormatException nfx) {
sender.sendMessage("Invalid max zoom out: " + minzoom);
}
}
sender.sendMessage("Added set id:'" + set.getMarkerSetID() + "' (" + set.getMarkerSetLabel() + ")");
}
}
@@ -1006,6 +1019,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
id = parms.get(ARG_ID);
label = parms.get(ARG_LABEL);
prio = parms.get(ARG_PRIO);
minzoom = parms.get(ARG_MINZOOM);
if((id == null) && (label == null)) {
sender.sendMessage("<label> or id:<set-id> required");
return true;
@@ -1046,6 +1060,13 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
sender.sendMessage("Invalid priority: " + prio);
}
}
if(minzoom != null) {
try {
set.setMinZoom(Integer.valueOf(minzoom));
} catch (NumberFormatException nfx) {
sender.sendMessage("Invalid min zoom: " + minzoom);
}
}
sender.sendMessage("Set '" + set.getMarkerSetID() + "' updated");
}
else {
@@ -1097,7 +1118,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
Set<String> setids = new TreeSet<String>(api.markersets.keySet());
for(String s : setids) {
MarkerSet set = api.markersets.get(s);
sender.sendMessage(set.getMarkerSetID() + ": label:\"" + set.getMarkerSetLabel() + "\", hide:" + set.getHideByDefault() + ", prio:" + set.getLayerPriority());
sender.sendMessage(set.getMarkerSetID() + ": label:\"" + set.getMarkerSetLabel() + "\", hide:" + set.getHideByDefault() + ", prio:" + set.getLayerPriority() + ", minzoom:" + set.getMinZoom());
}
}
/* Add new icon */
@@ -1505,6 +1526,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
msdata.put("label", ms.getMarkerSetLabel());
msdata.put("hide", ms.getHideByDefault());
msdata.put("layerprio", ms.getLayerPriority());
msdata.put("minzoom", ms.getMinZoom());
HashMap<String, Object> markers = new HashMap<String, Object>();
for(Marker m : ms.getMarkers()) {
if(m.getWorld().equals(wname) == false) continue;
@@ -25,6 +25,7 @@ class MarkerSetImpl implements MarkerSet {
private boolean hide_by_def;
private boolean ispersistent;
private int prio = 0;
private int minzoom = 0;
MarkerSetImpl(String id) {
setid = id;
@@ -250,6 +251,7 @@ class MarkerSetImpl implements MarkerSet {
setnode.put("areas", anode);
setnode.put("hide", hide_by_def);
setnode.put("layerprio", prio);
setnode.put("minzoom", minzoom);
return setnode;
}
@@ -297,6 +299,7 @@ class MarkerSetImpl implements MarkerSet {
}
hide_by_def = node.getBoolean("hide", false);
prio = node.getInt("layerprio", 0);
minzoom = node.getInt("minzoom", 0);
ispersistent = true;
return true;
@@ -370,4 +373,18 @@ class MarkerSetImpl implements MarkerSet {
return match;
}
@Override
public void setMinZoom(int minzoom) {
if(this.minzoom != minzoom) {
this.minzoom = minzoom;
MarkerAPIImpl.markerSetUpdated(this, MarkerUpdate.UPDATED);
if(ispersistent)
MarkerAPIImpl.saveMarkers();
}
}
@Override
public int getMinZoom() {
return this.minzoom;
}
}
@@ -122,8 +122,10 @@ public class SnapshotCache {
private void processRefQueue() {
Reference<? extends ChunkSnapshot> ref;
while((ref = refqueue.poll()) != null) {
String k = snapcache.reverselookup.get(ref);
if(k != null) snapcache.remove(k);
String k = snapcache.reverselookup.remove(ref);
if(k != null) {
snapcache.remove(k);
}
}
}
/**
@@ -141,5 +143,16 @@ public class SnapshotCache {
public void resetStats() {
cache_attempts = cache_success = 0;
}
/**
* Cleanup
*/
public void cleanup() {
if(snapcache != null) {
snapcache.clear();
snapcache.reverselookup.clear();
snapcache.reverselookup = null;
snapcache = null;
}
}
}
+3
View File
@@ -44,6 +44,8 @@ components:
- class: org.dynmap.SimpleWebChatComponent
allowchat: true
# If true, web UI users can supply name for chat using 'playername' URL parameter. 'trustclientname' must also be set true.
allowurlname: false
#- class: org.dynmap.herochat.HeroWebChatComponent
# # Control which HeroChat channel messages from web are directed to
# herochatwebchannel: Global
@@ -67,6 +69,7 @@ components:
#offlinelabel: "Offline"
#offlineicon: offlineuser
#offlinehidebydefault: true
#offlineminzoom: 0
- class: org.dynmap.ClientComponent
type: chat
+6 -1
View File
@@ -17,11 +17,16 @@ componentconstructors['chat'] = function(dynmap, configuration) {
}
});
});
var pname = null;
if(configuration.allowurlname) {
pname = dynmap.getParameterByName("chatname");
if(pname == "") pname = null;
}
if (dynmap.options.allowwebchat) {
// Accepts 'sendchat'-events to send chat messages to the server.
$(dynmap).bind('sendchat', function(event, message) {
var data = '{"name":'+JSON.stringify(ip?ip:"")+',"message":'+JSON.stringify(message)+'}';
var data = '{"name":'+JSON.stringify(pname?pname:(ip?ip:""))+',"message":'+JSON.stringify(message)+'}';
$.ajax({
type: 'POST',
url: config.url.sendmessage,
+12 -3
View File
@@ -40,6 +40,7 @@ DynMap.prototype = {
serverday: false,
inittime: new Date().getTime(),
followingPlayer: '',
initfollow: null,
missedupdates: 0,
layercontrol: undefined,
formatUrl: function(name, options) {
@@ -115,6 +116,10 @@ DynMap.prototype = {
if(typeof me.options.defaultzoom == 'undefined')
me.options.defaultzoom = 1;
var initfollowplayer = me.getParameterByName('playername');
if(initfollowplayer != "")
me.initfollow = initfollowplayer;
var map = this.map = new L.Map(mapContainer.get(0), {
zoom: me.options.defaultzoom,
center: new L.LatLng(0, 0),
@@ -140,10 +145,10 @@ DynMap.prototype = {
});
window.map = map; // Placate Leaflet need for top-level 'map'....
map.zoom_changed = function() {
me.maptype.updateTileSize(me.map.zoom);
map.on('zoomend', function() {
me.maptype.updateTileSize(me.map.getZoom());
$(me).trigger('zoomchanged');
};
});
/*google.maps.event.addListener(map, 'dragstart', function(mEvent) {
me.followPlayer(null);
@@ -556,6 +561,10 @@ DynMap.prototype = {
me.updatePlayer(player, playerUpdate);
} else {
me.addPlayer(playerUpdate);
if(me.initfollow && me.initfollow == name) {
me.followPlayer(me.players[name]);
me.initfollow = null;
}
}
newplayers[name] = player;
});
+58 -16
View File
@@ -24,7 +24,7 @@ componentconstructors['markers'] = function(dynmap, configuration) {
$.each(data.sets, function(name, markerset) {
var ms = dynmapmarkersets[name];
if(!ms) {
ms = { id: name, label: markerset.label, hide: markerset.hide, layerprio: markerset.layerprio, markers: {}, areas: {} } ;
ms = { id: name, label: markerset.label, hide: markerset.hide, layerprio: markerset.layerprio, minzoom: markerset.minzoom, markers: {}, areas: {} } ;
createMarkerSet(ms, ts);
}
else {
@@ -92,7 +92,8 @@ componentconstructors['markers'] = function(dynmap, configuration) {
$(popup).addClass('MarkerPopup').append(marker.desc);
marker.our_marker.bindPopup(popup, {});
}
set.layergroup.addLayer(marker.our_marker);
if((set.minzoom < 1) || (dynmap.map.getZoom() >= set.minzoom))
set.layergroup.addLayer(marker.our_marker);
}
function createMarkerSet(set, ts) {
@@ -108,6 +109,9 @@ componentconstructors['markers'] = function(dynmap, configuration) {
function createArea(set, area, ts) {
var style = { color: area.color, opacity: area.opacity, weight: area.weight, fillOpacity: area.fillopacity, fillColor: area.fillcolor, smoothFactor: 0.0 };
if(area.our_area && dynmap.map.hasLayer(area.our_area))
set.layergroup.removeLayer(area.our_area);
if(area.x.length == 2) { /* Only 2 points */
if(area.ytop == area.ybottom) {
area.our_area = create2DBoxLayer(area.x[0], area.x[1], area.ytop, area.ybottom, area.z[0], area.z[1], style);
@@ -138,7 +142,9 @@ componentconstructors['markers'] = function(dynmap, configuration) {
}
area.our_area.bindPopup(popup, {});
}
set.layergroup.addLayer(area.our_area);
if((set.minzoom < 1) || (dynmap.map.getZoom() >= set.minzoom)) {
set.layergroup.addLayer(area.our_area);
}
}
// Helper functions
@@ -242,18 +248,21 @@ componentconstructors['markers'] = function(dynmap, configuration) {
}
else if(msg.msg == 'setupdated') {
if(!dynmapmarkersets[msg.id]) {
dynmapmarkersets[msg.id] = { id: msg.id, label: msg.label, layerprio: msg.layerprio, markers:{} };
dynmapmarkersets[msg.id] = { id: msg.id, label: msg.label, layerprio: msg.layerprio, minzoom: msg.minzoom, markers:{} };
createMarkerSet(dynmapmarkersets[msg.id]);
}
else {
if(dynmapmarkersets[msg.id].label != msg.label) {
if((dynmapmarkersets[msg.id].label != msg.label) || (dynmapmarkersets[msg.id].layerprio != msg.layerprio)) {
dynmapmarkersets[msg.id].label = msg.label;
dynmapmarkersets[msg.id].layerprio = msg.layerprio;
//dynmap.layercontrol.removeLayer(dynmapmarkersets[msg.id].layergroup);
//dynmap.layercontrol.addOverlay(dynmapmarkersets[msg.id].layergroup, dynmapmarkersets[msg.id].label);
dynmap.addToLayerSelector(dynmapmarkersets[msg.id].layergroup, dynmapmarkersets[msg.id].label,
dynmapmarkersets[msg.id].layerprio || 0);
}
if(dynmapmarkersets[msg.id].minzoom != msg.minzoom) {
dynmapmarkersets[msg.id].minzoom = msg.minzoom;
}
}
}
else if(msg.msg == 'setdeleted') {
@@ -297,19 +306,52 @@ componentconstructors['markers'] = function(dynmap, configuration) {
});
// Remove marker on map change - let update place it again
$(dynmap).bind('mapchanged', function(event) {
var zoom = dynmap.map.getZoom();
$.each(dynmapmarkersets, function(setname, set) {
$.each(set.markers, function(mname, marker) {
var marker = set.markers[mname];
var markerPosition = getPosition(marker);
marker.our_marker.setLatLng(markerPosition);
if(dynmap.map.hasLayer(marker.our_marker) == false)
set.layergroup.addLayer(marker.our_marker);
});
$.each(set.areas, function(aname, area) {
createArea(set, area, area.timestamp);
});
if((set.minzoom < 1) || (zoom >= set.minzoom)) {
$.each(set.markers, function(mname, marker) {
var marker = set.markers[mname];
var markerPosition = getPosition(marker);
marker.our_marker.setLatLng(markerPosition);
if(dynmap.map.hasLayer(marker.our_marker) == false)
set.layergroup.addLayer(marker.our_marker);
});
$.each(set.areas, function(aname, area) {
createArea(set, area, area.timestamp);
});
}
});
});
$(dynmap).bind('zoomchanged', function(event) {
var zoom = dynmap.map.getZoom();
$.each(dynmapmarkersets, function(setname, set) {
if(set.minzoom > 0) {
if(zoom >= set.minzoom) {
$.each(set.markers, function(mname, marker) {
var marker = set.markers[mname];
var markerPosition = getPosition(marker);
marker.our_marker.setLatLng(markerPosition);
if(dynmap.map.hasLayer(marker.our_marker) == false)
set.layergroup.addLayer(marker.our_marker);
});
$.each(set.areas, function(aname, area) {
if(dynmap.map.hasLayer(area.our_area))
set.layergroup.removeLayer(area.our_area);
createArea(set, area, area.timestamp);
});
}
else {
$.each(set.markers, function(mname, marker) {
set.layergroup.removeLayer(marker.our_marker);
});
$.each(set.areas, function(aname, area) {
set.layergroup.removeLayer(area.our_area);
});
}
}
});
});
// Load markers for new world
$(dynmap).bind('worldchanged', function(event) {
loadmarkers(this.world.name);