jonatkins / s2-geometry-javascript

Porting Google's S2 Geometry Library to Javascript
31 stars 17 forks source link

'L' is not defined #2

Closed coolaj86 closed 8 years ago

coolaj86 commented 8 years ago

Where does one find 'L'?

Everyone is trying to implement their Pokemon GO clients in the browser, but if I could figure out what the 'L' is wrong with this library, I could take it to the browser, where it belongs. :D

In the meantime, I'm doing this: https://github.com/Daplie/node-pokemap/issues/1

coolaj86 commented 8 years ago

Is this the missing L?

https://searchcode.com/codesearch/view/42525008/

var L = { LatLng: {} };

L.LatLng.DEG_TO_RAD = Math.PI / 180;
L.LatLng.RAD_TO_DEG = 180 / Math.PI;

L.LatLng = function (/*Number*/ rawLat, /*Number*/ rawLng, /*Boolean*/ noWrap) {
    var lat = parseFloat(rawLat),
        lng = parseFloat(rawLng);

    if (isNaN(lat) || isNaN(lng)) {
        throw new Error('Invalid LatLng object: (' + rawLat + ', ' + rawLng + ')');
    }

    if (noWrap !== true) {
        lat = Math.max(Math.min(lat, 90), -90);                 // clamp latitude into -90..90
        lng = (lng + 180) % 360 + ((lng < -180 || lng === 180) ? 180 : -180);   // wrap longtitude into -180..180
    }

    return { lat: lat, lng: lng };
};
jonatkins commented 8 years ago

L will be the LeafletJS Javascript map library. http://leafletjs.com/

coolaj86 commented 8 years ago

Well... how about we just pull request that right in there then!?

...