extract bounds conversion from Map.Geolocation.Also fix geolocation test page.
This commit is contained in:
parent
4f06ac30b0
commit
f3b132e414
@ -8,7 +8,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../css/screen.css" />
|
||||
|
||||
<script type="text/javascript" src="../../build/deps.js"></script>
|
||||
<script src="../leaflet-include.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -40,7 +40,16 @@ L.LatLng.prototype = {
|
||||
|
||||
wrap: function () {
|
||||
return L.CRS.Earth.wrapLatLng(this);
|
||||
}
|
||||
},
|
||||
|
||||
toBounds: function (sizeInMeters) {
|
||||
var latAccuracy = 180 * sizeInMeters / 40075017,
|
||||
lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
|
||||
|
||||
return L.latLngBounds(
|
||||
[this.lat - latAccuracy, this.lng - lngAccuracy],
|
||||
[this.lat + latAccuracy, this.lng + lngAccuracy]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -66,14 +66,7 @@ L.Map.include({
|
||||
var lat = pos.coords.latitude,
|
||||
lng = pos.coords.longitude,
|
||||
latlng = new L.LatLng(lat, lng),
|
||||
|
||||
latAccuracy = 180 * pos.coords.accuracy / 40075017,
|
||||
lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * lat),
|
||||
|
||||
bounds = L.latLngBounds(
|
||||
[lat - latAccuracy, lng - lngAccuracy],
|
||||
[lat + latAccuracy, lng + lngAccuracy]),
|
||||
|
||||
bounds = latlng.toBounds(pos.coords.accuracy),
|
||||
options = this._locateOptions;
|
||||
|
||||
if (options.setView) {
|
||||
|
Loading…
Reference in New Issue
Block a user