Merge pull request #335 from mikeprimm/master

Fix various new map issues
This commit is contained in:
mikeprimm 2011-07-27 19:30:11 -07:00
commit f13b0b6c46

View File

@ -102,7 +102,7 @@ DynMap.prototype = {
me.options.defaultzoom = urlzoom; me.options.defaultzoom = urlzoom;
var map = this.map = new L.Map(mapContainer.get(0), { var map = this.map = new L.Map(mapContainer.get(0), {
zoom: 1, //TODO: me.options.defaultzoom || 1, zoom: me.options.defaultzoom || 1,
center: new L.LatLng(0, 0), center: new L.LatLng(0, 0),
zoomAnimation: true, zoomAnimation: true,
crs: L.Util.extend({}, L.CRS, { crs: L.Util.extend({}, L.CRS, {
@ -180,16 +180,16 @@ DynMap.prototype = {
.data('world', world) .data('world', world)
.appendTo(worldlist); .appendTo(worldlist);
$.each(world.maps, function(index, map) { $.each(world.maps, function(mapindex, map) {
//me.map.mapTypes.set(map.world.name + '.' + map.name, map); //me.map.mapTypes.set(map.world.name + '.' + map.name, map);
map.element = $('<li/>') map.element = $('<li/>')
.addClass('map') .addClass('map')
.append($('<a/>') .append($('<a/>')
.attr({ title: map.title, href: '#' }) .attr({ title: map.options.title, href: '#' })
.addClass('maptype') .addClass('maptype')
.css({ backgroundImage: 'url(' + (map.icon || 'images/block_' + map.name + '.png') + ')' }) .css({ backgroundImage: 'url(' + (map.options.icon || ('images/block_' + mapindex + '.png')) + ')' })
.text(map.title) .text(map.options.title)
) )
.click(function() { .click(function() {
me.selectMap(map); me.selectMap(map);
@ -307,21 +307,33 @@ DynMap.prototype = {
} }
$('.compass').addClass('compass_' + map.compassview); $('.compass').addClass('compass_' + map.compassview);
$('.compass').addClass('compass_' + map.name); $('.compass').addClass('compass_' + map.name);
var worldChanged = me.world !== map.world; var worldChanged = me.world !== map.options.world;
var projectionChanged = (me.maptype && me.maptype.getProjection()) !== (map && map.projection); var projectionChanged = (me.maptype && me.maptype.getProjection()) !== (map && map.projection);
var prevzoom = me.map.getZoom();
if (me.maptype) { if (me.maptype) {
me.map.removeLayer(me.maptype); me.map.removeLayer(me.maptype);
} }
me.world = mapWorld; me.world = mapWorld;
me.maptype = map; me.maptype = map;
if (projectionChanged || worldChanged) { if (projectionChanged || worldChanged) {
var centerLocation = $.extend({ x: 0, y: 64, z: 0 }, mapWorld.center); var centerPoint;
var centerPoint = me.getProjection().fromLocationToLatLng(centerLocation); if(worldChanged) {
var centerLocation = $.extend({ x: 0, y: 64, z: 0 }, mapWorld.center);
centerPoint = me.getProjection().fromLocationToLatLng(centerLocation);
}
else {
centerPoint = me.map.getCenter();
}
me.map.setView(centerPoint, 0, true); me.map.setView(centerPoint, 0, true);
} }
me.map.addLayer(me.maptype);
me.map.addLayer(me.maptype, false); me.map.setZoom(prevzoom);
if (worldChanged) { if (worldChanged) {
$(me).trigger('worldchanged'); $(me).trigger('worldchanged');