This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
data() { | |
return { | |
lat: 0, | |
lng: 0, | |
type: "", | |
radius: "", | |
places: [] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<img src="https://via.placeholder.com/150" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const URL = `https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${ | |
this.lat | |
},${this.lng}&type=${this.type}&radius=${this.radius * 1000}&key=${ | |
this.apiKey | |
}`; | |
axios | |
.get(URL) | |
.then(response => { | |
console.log(response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController{ | |
private let latLngLabel: UILabel = { | |
let label = UILabel() | |
label.backgroundColor = .systemFill | |
label.numberOfLines = 0 | |
label.textAlignment = .center | |
label.font = .systemFont(ofSize: 26) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="ui grid"> | |
<div class="six wide column"></div> | |
<div class="ten wide column segment ui" ref="map"></div> | |
</div> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="six wide column"> | |
<form class="ui segment large form"> | |
<div class="ui segment"> | |
<div class="field"> | |
<div class="ui right icon input large"> | |
<input type="text" placeholder="Enter your address" v-model="coordinates" /> | |
<i class="dot circle link icon" @click="locatorButtonPressed"></i> | |
</div> | |
</div> | |
<div class="field"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data() { | |
return { | |
lat: 0, | |
lng: 0, | |
type: "", | |
radius: "", | |
places: [] | |
}; | |
}, | |
computed: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
methods: { | |
locatorButtonPressed() { | |
navigator.geolocation.getCurrentPosition( | |
position => { | |
this.lat = position.coords.latitude; | |
this.lng = position.coords.longitude; | |
}, | |
error => { | |
console.log("Error getting location"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findCloseBuyButtonPressed() { | |
const URL = `https://cors-anywhere.herokuapp.com/https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${ | |
this.lat | |
},${this.lng}&type=${this.type}&radius=${this.radius * | |
1000}&key=[YOURAPIKEY]`; | |
axios | |
.get(URL) | |
.then(response => { | |
this.places = response.data.results; | |
this.addLocationsToGoogleMaps(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="ui segment" style="max-height:500px;overflow:scroll"> | |
<div class="ui divided items"> | |
<div class="item" v-for="place in places" :key="place.id"> | |
<div class="content"> | |
<div class="header">{{place.name}}</div> | |
<div class="meta">{{place.vicinity}}</div> | |
</div> | |
</div> | |
</div> | |
</div> |