【问题标题】:issue with here map geocode这里地图地理编码的问题
【发布时间】:2017-04-28 20:48:50
【问题描述】:

这里的地图 API 有问题。

我想为地图实现第一个默认位置。当用户搜索某个位置时,它应该移动到该位置。简单对。但我有点失落。

//i define parameter.
var geocodingParams = { searchText: 'location address' };

// Get an instance of the geocoding service:
var geocoder = platform.getGeocodingService();

// Call the geocode method with the geocoding parameters,
// the callback and an error callback function (called if a
// communication error occurs):
geocoder.geocode(geocodingParams, onResult, onError);

// results when success
function onResult(result) {
        var locations = result.response.view[0].result;
        alert(JSON.stringify(locations));
}

// on Error
function onError(e) {
        alert(e);
}

它只给出错误。我们将不胜感激。

【问题讨论】:

    标签: dictionary here-api geocode


    【解决方案1】:

    之所以抛出错误是因为找不到地址'location address'。

    我认为您应该将地址更改为“425 W Randolph Chicago”,然后重试。

    如果还是不行,试试把result.response.view[0].result;改成result.Response.View[0].Result; 另外,您可以做的是检查您是否收到任何回复:

    if(result.Response.View) 
                {
                var locations = result.Response.View[0].Result;
                alert(JSON.stringify(locations));
                }
    else
    alert("Blank response");`
    

    【讨论】:

      猜你喜欢
      • 2010-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多