Jquery 我试图在我的谷歌地图上显示所有的家庭仓库
我是谷歌地图的新手。我正在尝试制作一张地图,使用Kmlayer显示整个美国的销售区域。这部分是成功的 我现在想把所有的家得宝都作为标记显示出来,这样理论上,你可以浏览地图,看看你的地盘,看看你所在地区的所有家得宝 以下是我到目前为止的情况:Jquery 我试图在我的谷歌地图上显示所有的家庭仓库,jquery,google-maps-api-3,geocoding,google-maps-markers,Jquery,Google Maps Api 3,Geocoding,Google Maps Markers,我是谷歌地图的新手。我正在尝试制作一张地图,使用Kmlayer显示整个美国的销售区域。这部分是成功的 我现在想把所有的家得宝都作为标记显示出来,这样理论上,你可以浏览地图,看看你的地盘,看看你所在地区的所有家得宝 以下是我到目前为止的情况: $(document).ready(function() { var map, geocoder; init(); $('.showVendors').click(function() { loadKML();
$(document).ready(function() {
var map, geocoder;
init();
$('.showVendors').click(function() {
loadKML();
showVendors();
});
});
function init() {
var myOptions = {
center: new google.maps.LatLng(37.09024,-95.712891),
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), myOptions);
geocoder = new google.maps.Geocoder();
}
function loadKML() {
var kmlOptions = {
clickable: true,
map: map,
preserveViewport: true,
suppressInfoWindows: false
}
var kmlLayer = new google.maps.KmlLayer('kml/territories.kml', kmlOptions);
}
function showVendors() {
var vendor = 'Home Depot';
geocoder.geocode( { 'premise' : vendor }, function(results, status) {
if ( status == google.maps.GeocoderStatus.OK ) {
map.setCenter(results[1].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[1].geometry.location
});
} else {
alert ( "Geocode was unsuccessful for the following reason: " + status );
}
});
}
当我通过API直接运行您的查询时:
http://maps.googleapis.com/maps/api/geocode/json?premise=Home%20Depot&sensor=true
我得到:
{
"results" : [],
"status" : "ZERO_RESULTS"
}
看起来此信息在地理编码API中不可用,这是您在上面使用的代码。使用places API会有更好的运气,但它仍然是实验性的:
Google Places提供了我一直在寻找的解决方案。谢谢你把我推向正确的方向!美好的很高兴我能帮忙。