Skip to content

Commit

Permalink
Add attribution control banner
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorntonMatthewD committed Oct 8, 2023
1 parent 7da7dfc commit 453072b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
15 changes: 15 additions & 0 deletions cypress/e2e/map.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,19 @@ describe("Map", () => {

cy.url().should("not.contain", "lng=-82.401078");
});

it.only("Attribution control displays the proper message and link", () => {
loadMap("/");

cy.get(".leaflet-control-attribution").contains(
"Brought to you by HackGreenville Labs. Click here to contribute!"
);

// Get contribution link and ensure that the URL is as expected
cy.get(
".leaflet-control-container > div.leaflet-bottom.leaflet-right > div > a:nth-child(2)"
)
.should("have.attr", "href")
.and("match", /https:\/\/data.openupstate.org\/contribute/);
});
});
1 change: 1 addition & 0 deletions src/@vue-leaflet/vue-leaflet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ declare module "@vue-leaflet/vue-leaflet" {
import type { DefineComponent } from "vue";
export const LMap: DefineComponent;
export const LTileLayer: DefineComponent;
export const LControlAttribution: DefineComponent;
}
16 changes: 14 additions & 2 deletions src/components/MainMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import type { Map, GeoJSON, LayersControlEvent } from "leaflet";
</script>

<script setup lang="ts">
import { LMap, LTileLayer } from "@vue-leaflet/vue-leaflet";
import {
LMap,
LTileLayer,
LControlAttribution,
} from "@vue-leaflet/vue-leaflet";
import { useMapStore } from "../stores/map";
import { useRoute, useRouter } from "vue-router";
import type { Feature } from "geojson";
Expand Down Expand Up @@ -203,13 +207,21 @@ function toTitleCase(string: string) {
:minZoom="7"
:maxZoom="20"
:center="mapStore.locationArray"
:options="{
attributionControl: false,
}"
@ready="initializeMap"
>
<l-control-attribution
position="bottomright"
prefix="Brought to you by <a href='https://hackgreenville.com/'>HackGreenville Labs</a>. <a href='https://data.openupstate.org/contribute'>Click here</a> to contribute!"
/>
<l-tile-layer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
layer-type="base"
name="OpenStreetMap"
></l-tile-layer>
attribution="© <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
/>
</l-map>
</div>
</template>

0 comments on commit 453072b

Please sign in to comment.