Computer Magic Logo
Create a marker

Thursday, December 1, 2016

Published by Aristotelis Pitaridis

A marker is used in order to identify a location on the map. The following example demonstrates how to put a marker on the map.

<!DOCTYPE html>
<html>
<head>
    <style>
        #map {
            height: 400px;
            width: 600px;
        }
    </style>
</head>
<body>
    <h3>My Google Maps Demo</h3>
    <div id="map"></div>
    <script>
        function initMap() {
            var location = { lat: 35.339186, lng: 25.1315903 };
            var map = new google.maps.Map(document.getElementById('map'), {
                zoom: 12,
                center: location
            });
            var marker = new google.maps.Marker({
                position: location,
                map: map
            });
        }
    </script>
    <script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script>
</body>
</html>