我试图在谷歌地图上制作基于地址的标记,但是地图显示没有数据?
这是我的例子
***Service
HTML
$(document).ready(function() {
/* google maps */
google.maps.visualRefresh = true;
var geocoder = new google.maps.Geocoder();
var mapOptions = {
zoom: 14, // set the zoom level manually
zoomControl: false,
scaleControl: false,
scrollwheel: false,
disableDoubleClickZoom: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map;
function initialize() {
var address = $('#map').text(); /* change the map-input to your address */
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
if (geocoder) {
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
map.setCenter(results[0].geometry.location);
var infowindow = new google.maps.InfoWindow({
content: address,
map: map,
position: results[0].geometry.location,
});
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: address
});
} else {
alert("No results found");
}
}
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
});