Skip to content

Commit

Permalink
Conversion from Esri to Leaflet polygon now in
Browse files Browse the repository at this point in the history
its own function within Map.vue (issue #7). Should be abstracted further
  • Loading branch information
dannarsavage committed Apr 4, 2021
1 parent 4f300fc commit 5a8ad2b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ export default {
},
setCounty: async function (countyReference) {
this.clearCounties();
// if (countyReference.Shape === null) {
if (countyReference.Shape === null) {
countyReference.Shape = await this.retrieveShape(countyReference);
// }
countyReference.Shape.addTo(this.countyLayerGroup);
this.map.flyToBounds(countyReference.Shape.getBounds());
}
const countyShape = this.convertEsriPolygonToLeaflet(countyReference.Shape);
countyShape.addTo(this.countyLayerGroup);
this.map.flyToBounds(countyShape.getBounds());
},
retrieveShape: async function(countyReference) {
const countyReturn = await this.countyClient.getCountyByStateAndCountyId (
countyReference.StateId, countyReference.CountyId, true);
// TODO: Do the work of converting from an Esri geometry to a leaflet geometry somewhere else
const ring = countyReturn.Shape.rings[0];
return countyReturn.Shape;
},
convertEsriPolygonToLeaflet: function (esriPolygon) {
const ring = esriPolygon.rings[0];
const latlngs = [];
ring.forEach(element => {
latlngs.push([element[1],element[0]]);
Expand Down

0 comments on commit 5a8ad2b

Please sign in to comment.