Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
henrythasler committed Nov 23, 2019
1 parent 0144773 commit eba99a8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Add-on for [Leaflet](http://leafletjs.com/) to draw [geodesic](http://en.wikiped

[Live Demos and Tutorials](https://blog.cyclemap.link/Leaflet.Geodesic/)

[API-Documentation](https://blog.cyclemap.link/Leaflet.Geodesic/api)

## Add the plugin to your project

Leaflet.Geodesic is available via CDN. Add the following snippet to your html-file after you have [included leaflet.js](https://leafletjs.com/examples/quick-start/).
Expand Down Expand Up @@ -139,11 +141,23 @@ const geodesic = new L.Geodesic().addTo(map); // add empty object to the map

const Berlin = new L.LatLng(52.5, 13.35);
const LosAngeles = new L.LatLng(33.82, -118.38);

geodesic.setLatLngs([Berlin, LosAngeles]) // update in-place
```

The `setLatLngs()`-Method accepts the same types (Literal, Tuple, LatLang-Class, Linstring, Multilinestring) as the L.Geodesic-constructor itself. Please refer to the section about geodesic circles below, on how to update a circle geometry.

Points can be added to existing geodesic lines with `addLatLng()`:

```Javascript
const Berlin = new L.LatLng(52.5, 13.35);
const LosAngeles = new L.LatLng(33.82, -118.38);
const Beijing = new L.LatLng(39.92, 116.39);

const geodesic = new L.Geodesic([Berlin, LosAngeles]).addTo(map); // add empty object to the map
geodesic.addLatLng(Beijing)
```

### Line Options
All options defined for [Polyline](http://leafletjs.com/reference.html#polyline) and [Path](https://leafletjs.com/reference.html#path) for can be used Leaflet.Geodesic.

Expand Down
2 changes: 1 addition & 1 deletion docs/testing-measurement.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
let vector = geodesic.geom.geodesic.inverse(marker.getLatLng(), e.latlng);
const totalDistance = (vector.distance !== undefined ? (vector.distance > 10000) ? (vector.distance / 1000).toFixed(0) + ' km' : (vector.distance).toFixed(0) + ' m' : 'invalid')
marker.setLatLng(e.latlng);
marker.setTooltipContent(`Distance: +${totalDistance}</br>Bearing: ${vector.finalBearing.toFixed(0)}°`);
marker.setTooltipContent(`<b>Segment</b></br>Distance: +${totalDistance}</br>Bearing: ${vector.finalBearing.toFixed(0)}°`);
marker.openTooltip();
info.update(geodesic.statistics);
});
Expand Down
12 changes: 1 addition & 11 deletions docs/testing.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,7 @@
steps: 5,
}).addTo(map);

info.update(geodesic.statistics);

const geo = L.geodesic();
console.log(geo.geom.geodesic.inverse(berlin, losangeles))
console.log(geo.geom.geodesic.midpoint(berlin, losangeles))

geo.addLatLng(losangeles);
geo.addLatLng(berlin);
geodesic.addLatLng(Beijing);
geo.addTo(map);

info.update(geodesic.statistics);

A.on('drag', (e) => {
// console.log(`A=${e.latlng}`);
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"build": "rm -f dist/* && rollup -c && npm run integrity:create && npm run integrity:show && npm run build:stats && cp dist/leaflet.geodesic.umd.min.js docs/"
},
"np": {
"publish": false,
"releaseDraft": false
"publish": false
}
}

0 comments on commit eba99a8

Please sign in to comment.