Google map V3 Set Center to specific Marker

后端 未结 6 839
深忆病人
深忆病人 2020-12-05 13:04

I am using Google Map V3 to display a list of markers pulled from a DB, using MYsql and PHP. MY markers are set on the map using the full address (from DB, including postcod

6条回答
  •  温柔的废话
    2020-12-05 13:27

    geocoder.geocode( { 'address': address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          map.setCenter(results[0].geometry.location);
          var marker = new google.maps.Marker({
              map: map,
              position: results[0].geometry.location
          });
        } else {
          alert('Geocode was not successful for the following reason: ' + status);
        }
      });
    

提交回复
热议问题