知道如何使用init GeoComplete定位(使引脚掉线)吗?

 $("#geocomplete").geocomplete({
    map: ".map_canvas",
    location: [52.4078567, 16.92718339999999], // is it centring the map, no pin thought
    markerOptions: {
        draggable: true
    },
    details: "form",
    types: ["geocode", "establishment"]

});


上面的示例确实使地图居中,但没有放置图钉。为什么?
在线演示here

最佳答案

在初始化时指定经度和纬度时,该销钉似乎没有放置。

另一种方法是从初始化中删除location选项,并在创建geocomplete实例后立即对默认位置进行一次搜索:

// Run this function once after the first search
$("#geocomplete").geocomplete(options)
  .one("geocode:result", function(event, result){

    // Set the zoom level you require for the default map
    var map = $("#geocomplete").geocomplete("map");
    map.setZoom(13);

    // Optionally empty the geocomplete input field
    $("#geocomplete").val("");

});


随后是按地址查找:

$("#geocomplete").geocomplete("find", "Poznań, Poland");


或按经纬度:

var lat_and_long = "52.4078567, 16.9271833";
$("#geocomplete").geocomplete("find", lat_and_long);

10-06 07:54