Ignore:
Timestamp:
Aug 31, 2014, 4:46:56 PM (7 years ago)
Author:
alloc
Message:

Webserver files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements/webserver/js/index.js

    r133 r149  
    1818});
    1919
     20var CoordToChunk = function(latlng) {
     21        var x = Math.floor(((latlng.lng + 16777216) / 16) - (16777216 / 16));
     22        var y = Math.floor(((latlng.lat + 16777216) / 16) - (16777216 / 16));
     23        return L.latLng(y, x);
     24}
     25
     26var CoordToRegion = function(latlng) {
     27        var x = Math.floor(((latlng.lng + 16777216) / 512) - (16777216 / 512));
     28        var y = Math.floor(((latlng.lat + 16777216) / 512) - (16777216 / 512));
     29        return L.latLng(y, x);
     30}
     31
     32var FormatCoord = function(latlng) {
     33        return Math.abs(latlng.lat)+ (latlng.lat>=0 ? " N" : " S") + " / " + Math.abs(latlng.lng) + (latlng.lng>=0 ? " E" : " W");
     34}
     35
    2036var map = L.map('map', {
    2137        zoomControl: true,
     
    3551}).addTo(map);
    3652
     53
    3754map.on('mousemove', function(e) {
    38         L.DomUtil.get('pos').textContent = "MouseCoord: " + Math.abs(e.latlng.lng) + (e.latlng.lng>=0 ? " E" : " W") + " / " + Math.abs(e.latlng.lat)+ (e.latlng.lat>=0 ? " N" : " S");
     55        var rf = CoordToRegion(e.latlng);
     56        L.DomUtil.get('pos').textContent = FormatCoord(e.latlng);
     57        L.DomUtil.get('regfile').textContent = "r." + rf.lng + "." + rf.lat + ".7rg";
    3958});
Note: See TracChangeset for help on using the changeset viewer.