Google Maps Javascript

Aug 24, 2018
Load Map, Add Marker, Zoom To Marker

Get API Key and Include Javascript for Google Map/Places.

Load Map

<div id="map" style="height: 300px;"></div>
const mapCenter = new google.maps.LatLng(-33.8617374,151.2021291)const map = new google.maps.Map(document.getElementById('map'), {  center: mapCenter,  zoom: 15})

Place Marker

const marker = new google.maps.Marker({ position: new google.maps.LatLng(-33.8617374,151.2021291), map: map, title: "Test" })

Move Marker and Pan Map

const newLocation = new google.maps.LatLng(35.652832,139.839478)marker.setPosition(newLocation)marker.setTitle('Tokyo')map.panTo(newLocation)

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.