Skip to content

Instantly share code, notes, and snippets.

@timdeschryver
Created November 3, 2019 16:24
Show Gist options
  • Select an option

  • Save timdeschryver/24b8c8cc75c236f9c75d50109d6f33d9 to your computer and use it in GitHub Desktop.

Select an option

Save timdeschryver/24b8c8cc75c236f9c75d50109d6f33d9 to your computer and use it in GitHub Desktop.
export class AppComponent implements OnInit {
zoom = 12
center: google.maps.LatLngLiteral
options: google.maps.MapOptions = {
mapTypeId: 'hybrid',
zoomControl: false,
scrollwheel: false,
disableDoubleClickZoom: true,
maxZoom: 15,
minZoom: 8,
}
ngOnInit() {
navigator.geolocation.getCurrentPosition(position => {
this.center = {
lat: position.coords.latitude,
lng: position.coords.longitude,
}
})
}
zoomIn() {
if (this.zoom < this.options.maxZoom) this.zoom++
}
zoomOut() {
if (this.zoom > this.options.minZoom) this.zoom--
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment