K
K
kentos2019-07-08 00:09:18
JavaScript
kentos, 2019-07-08 00:09:18

How to make dot move and popup?

Hello, I'm racking my brains on how to make the select redirect to the dot and popup popup

new google.maps.Marker({
            position: {lat: 53.877805, lng: 27.540712}, map: map
        });
        new google.maps.Marker({
            position: {lat: 39.489874, lng: -8.448817}, map: map
        });
        new google.maps.Marker({
            position: {lat: 52.519881, lng: 13.407338}, map: map
        });

        var geocoder = new google.maps.Geocoder();
  $("#city_dropdown").change(function() {
    address = $("#city_dropdown :selected")[0].text;
    console.log(address)
    geocodeAddress(address, geocoder, map);
  });
  var address = $("#city_dropdown :selected")[0].text;
  geocodeAddress(address, geocoder, map);

  function geocodeAddress(address, geocoder, resultsMap) {
    geocoder.geocode({
      'address': address
    }, function(results, status) {
      if (status === google.maps.GeocoderStatus.OK) {
        resultsMap.fitBounds(results[0].geometry.viewport);

        console.log(results[0].geometry.location.lat())
      } else {
        alert('Geocode was not successful for the following reason: ' + status);
      }
    });
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2019-07-08
@freeExec

Save a link to the marker and set a new position for it after geocoding. Close the old popup, open the new one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question