2011-01-06 74 views
0

http://gmaps-samples-v3.googlecode.com/svn/trunk/localsearch/places.html如何在Google Maps V3 API中構建這樣的東西?

在這個例子中,當我執行搜索時,我得到了很多結果。因爲這是使用本地搜索API。但在V3中,我只返回一個結果。我的代碼是:

var address = $("#id_address_input").val(); 
var geocoder = new google.maps.Geocoder(); 
geocoder.geocode({ 'address': address}, function(results, status) { 
if (status == google.maps.GeocoderStatus.OK) { 
    $("#badlocation_holder").hide(); 
    $("#map_canvas").show(); 
    $("#map_canvas_holder").show().css("background-color", "#E6E6FA").animate({"background-color":"#f5f5f5"}, 800); 
    var myOptions = { 
     zoom: 15, 
     center: results[0].geometry.location, 
     streetViewControl:false, 
     mapTypeControl:false, 
     mapTypeId: google.maps.MapTypeId.ROADMAP, 
     scrollwheel:false, 
    }; 

    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
    var marker = new google.maps.Marker({ 
      map: map, 
      position: results[0].geometry.location, 
      draggable:true 
    }); 

回答

1

本地搜索API已被棄用。看看可能適合您的要求的Places API。