V
V
Victor Umansky2017-06-03 13:26:30
JavaScript
Victor Umansky, 2017-06-03 13:26:30

Centering Geo points on google maps?

There are google maps, there are also div.blocks, each div.block has its own longitude and latitude of the city, and when you hover over each block, the city is displayed on the map (THIS WORKS). But I can't make it so that when you hover the mouse over the div.block, the map moves behind the geo point, that is, it is centered on the point.

var map = new google.maps.Map(document.getElementById('map'), {
                zoom: 8,
                center: new google.maps.LatLng(50.4501, 30.5234),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });

            var marker;
            marker = new google.maps.Marker({
                position: new google.maps.LatLng(50.4501, 30.5234),
                map: map
            });

            google.maps.event.addListener(map, 'click', function (event) {
                var lat = event.latLng.lat().toFixed(4);
                var lng = event.latLng.lng().toFixed(4);

                marker.setPosition(new google.maps.LatLng(lat, lng));
            });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2017-06-05
@Uman

map.setCenter(*);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question