<div id="map"></div>
<script>
// Custom CRS
L.CRS.Arma = L.extend({}, L.CRS, {
projection: L.Projection.LonLat,
transformation: new L.Transformation(1, 0, -1, 0),
scale: function (zoom) {
return Math.pow(2, zoom);
},
latLngToPoint: function(latlng, zoom) {
var adjlatlng = L.latLng((latlng.lat-this.adjust.y)/this.adjust.scale.y, (latlng.lng-this.adjust.x)/this.adjust.scale.x);
return L.CRS.Simple.latLngToPoint(adjlatlng, zoom);
},
pointToLatLng: function(point, zoom) {
var latlng = L.CRS.Simple.pointToLatLng(point, zoom);
latlng.lng = (latlng.lng*this.adjust.scale.x)+this.adjust.x;
latlng.lat = (latlng.lat*this.adjust.scale.y)+this.adjust.y;
return latlng;
},
adjust: {
x: 0.3,
y: 25.4,
scale: {
x: 2.3275,
y: 2.3275
}
}
});
var map = L.map('map', {
zoomControl: false,
crs: L.CRS.Arma
});
L.tileLayer('http://badkarmagaming.com/wp-content/plugins/arma-maps/maps/AltisZL5/{z}/{x}/{y}.png', {
maxZoom: 7,
minZoom: 2,
attribution: 'Web Map by <a href="http://forums.bistudio.com/showthread.php?178671-Tiled-maps-Google-maps-compatible-%28WIP%29">10T</a> (adapted by Razzmatazz), Altis by Bohemia Interactive',
noWrap: true,
tms: true,
continuousWorld: true
}).addTo(map);
map.setView([145, 133.5], 3);
new L.Control.Zoom({ position: 'topleft' }).addTo(map);
L.circle([145, 133.5], 300, {
color: 'green',
fillColor: '#0f3',
fillOpacity: 0.6
}).addTo(map).bindPopup("<b>Safe zone traders</b>");
var popup = L.popup();
function onMapClick(e) {
var x = e.latlng.lng.toFixed(1);
var y = e.latlng.lat.toFixed(1);
popup
.setLatLng(e.latlng)
.setContent(e.latlng.toString()+'<br>x: '+x+', y: '+y)
.openOn(map);
}
map.on('contextmenu', onMapClick);
</script>
L.MyCircle = L.Circle.extend({
initialize: function (latlng, radius, options) {
L.Circle.prototype.initialize.call(this, latlng, radius, options);
},
getBounds: function () {
var lngRadius = this._getLngRadius(),
latRadius = this._getLatRadius(),
latlng = this._latlng;
return new L.LatLngBounds(
[latlng.lat - latRadius, latlng.lng - lngRadius],
[latlng.lat + latRadius, latlng.lng + lngRadius]);
},
_getLatRadius: function () {
return (this._mRadius / 100.0);
},
_getLngRadius: function () {
return this._getLatRadius();
}
});
L.myCircle = function (latlng, radius, options) {
return new L.MyCircle(latlng, radius, options);
};