如何在Google Maps V3 API中构建类似的内容?

时间:2011-01-06 23:01:51

标签: javascript jquery google-maps

http://gmaps-samples-v3.googlecode.com/svn/trunk/localsearch/places.html

在此示例中,我在执行搜索时返回了许多结果。因为那是使用本地搜索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 个答案:

答案 0 :(得分:1)

不推荐使用Local Search API。看看Places API,它可能符合您的要求。