2
Использование Google Maps API, я хотел бы, чтобы центрировать карту в строку вместо LAT/LNGцентр Google Maps в строку местоположения
var mapOptions = {
center: "Paris"
};
Использование Google Maps API, я хотел бы, чтобы центрировать карту в строку вместо LAT/LNGцентр Google Maps в строку местоположения
var mapOptions = {
center: "Paris"
};
Вы можете использовать geocoder:
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var mapOptions = {
zoom: 8,
center: latlng
};
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
// Call the codeAddress function (once) when the map is idle (ready)
google.maps.event.addListenerOnce(map, 'idle', codeAddress);
}
function codeAddress() {
// Define address to center map to
var address = 'Paris, France';
geocoder.geocode({
'address': address
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// Center map on location
map.setCenter(results[0].geometry.location);
// Add marker on 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);
}
});
}
initialize();
Edit:, конечно, вы можете геокодировать полный адрес:
// Define address to center map to
var address = 'Rue Casse-Cul, Montboucher-sur-Jabron, France';
https://developers.google.com/maps/documentation/javascript/geocoding – MrUpsidown