Skip to content

Commit

Permalink
style: Auto adjust map size (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
purplebugs authored Oct 27, 2024
1 parent 252839f commit 5ae421f
Showing 1 changed file with 14 additions and 31 deletions.
45 changes: 14 additions & 31 deletions src/alpaca-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ export default class AlpacaMap extends LitElement {
background-color: white;
display: inline-block;
border: 1px solid black;
height: 500px;
width: 600px;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 85px 1fr 80px;
grid-template-rows: auto 5fr 1fr;
grid-column-gap: 0px;
grid-row-gap: 0px;
Expand Down Expand Up @@ -90,8 +88,8 @@ export default class AlpacaMap extends LitElement {
.header-container {
background-color: white;
margin: 0.5em;
overflow: hidden;
padding: 0.25em 0em 0.25em 0em;
}
.map-container {
Expand All @@ -102,7 +100,7 @@ export default class AlpacaMap extends LitElement {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.5em 0.5em 0.5em 0.5em;
padding: 0.5em 0em 0.5em 0em;
background-color: white;
Expand Down Expand Up @@ -199,32 +197,30 @@ export default class AlpacaMap extends LitElement {
constructor() {
super();
this.map;
this.apiKey = '';
this.apiKey = "";
this.centerLat = 60.472;
this.centerLng = 8.4689;
this.dataSource = "http://localhost:3000/api/companies"; // TODO set default depending on environment
this.farms = [];
this.cluster = null;
this.cluster = null;
}

connectedCallback() {
super.connectedCallback()
super.connectedCallback();

console.log('Using the followig ApiKey', this.apiKey)
console.log("Using the followig ApiKey", this.apiKey);

// Ref; https://developers.google.com/maps/documentation/javascript/load-maps-js-api#js-api-loader
const loader = new Loader({
apiKey: this.apiKey,
version: "weekly",
});

loader.load().then(async () => {
await this.initMap();
});
}



// When element has rendered markup in the DOM firstUpdated() is called
async initMap() {
async function fetchFarms(dataSource) {
Expand All @@ -233,11 +229,9 @@ export default class AlpacaMap extends LitElement {
const response = await fetch(dataSource);
const farms = await response.json();
// console.log("farms", farms);

arr = farms?.items || [];
} catch(error) {

}
arr = farms?.items || [];
} catch (error) {}
return arr;
}

Expand Down Expand Up @@ -327,7 +321,6 @@ export default class AlpacaMap extends LitElement {
map: this.map,
algorithmOptions: {
radius: 100,

},
});
this.cluster.addMarkers(markers);
Expand Down Expand Up @@ -404,11 +397,7 @@ export default class AlpacaMap extends LitElement {
</span>
<span class="toggle">
<input
type="checkbox"
id="alpacaWalking"
name="alpacaWalking"
/>
<input type="checkbox" id="alpacaWalking" name="alpacaWalking" />
<label for="alpacaWalking"
><alpaca-map-icon icon="personHiking"></alpaca-map-icon>Alpaca
walking</label
Expand All @@ -431,11 +420,7 @@ export default class AlpacaMap extends LitElement {
</span>
<span class="toggle">
<input
type="checkbox"
id="overnightStay"
name="overnightStay"
/>
<input type="checkbox" id="overnightStay" name="overnightStay" />
<label for="overnightStay"
><alpaca-map-icon icon="bed"></alpaca-map-icon>Overnight
stay</label
Expand All @@ -452,7 +437,7 @@ export default class AlpacaMap extends LitElement {
</div>
</form>
</header>
<div class="map-container" id="map"></div>
<footer class="footer-container">
Expand All @@ -471,9 +456,7 @@ export default class AlpacaMap extends LitElement {
<div class="footer-message">
Find alpacas,<br />
farms and more:<br />
<a href="https://www.alpaca.life" target="_blank"
>www.alpaca.life</a
>
<a href="https://www.alpaca.life" target="_blank">www.alpaca.life</a>
</div>
<div>
<a
Expand Down

0 comments on commit 5ae421f

Please sign in to comment.