【问题标题】:How do I build something like this in Google Maps V3 API?如何在 Google Maps V3 API 中构建类似的东西?
【发布时间】:2011-01-06 23:01:51
【问题描述】:

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
    });

【问题讨论】:

    标签: javascript jquery google-maps


    【解决方案1】:

    不推荐使用本地搜索 API。查看可能适合您要求的 Places API。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多