【问题标题】:cannot geocode in other browser无法在其他浏览器中进行地理编码
【发布时间】:2009-11-02 00:38:06
【问题描述】:

您好,我创建了一个混搭,用户可以在其中输入位置。使用 IE7 时,几乎所有位置都可以进行地理编码,但不能使用其他浏览器......您认为这里的问题是什么,或者有什么解决方法为此?我使用 javascript 地理编码,例如:

 function addToMap(response) {
       var x="Fa, France";
        // Retrieve the object
        if (x.length > 0 && x != "") {
            if (!response || response.Status.code != 200) {
                alert("Please enter a valid location.I cannot geocode it!"); 
            }
            else
            {
                place = response.Placemark[0];

                // Retrieve the latitude and longitude
                point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);

                // Center the map on this point
                map.setCenter(point, 4);}}

...更多代码

【问题讨论】:

  • 您是否尝试过在 Firefox 中使用 FireBug 来找出问题所在?尝试单步执行。
  • 我试过了,但没有错误.....一切都很好。
  • 您在输入的示例中缺少一些代码。 GClientGeocoder 在哪里?你在哪里打电话?我建议您发布“更多代码”或指向您的测试页面的链接?

标签: google-maps many-to-many mashup


【解决方案1】:

在最近的 API 版本中,必须使用数字作为 GLatLng() 的参数。在以前的版本中,您通常可以将它们保留为 String 对象,就像您正在做的那样。

尝试使用 parseFloat(place.Point.coordinates[1]), parseFloat(place.Point.coordinates[0])

我不知道为什么 MSIE7 会有所不同,或者为什么您在 Firebug 中没有收到明确的错误消息。也许有些事情你没有告诉我们。

【讨论】:

    猜你喜欢
    • 2020-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 1970-01-01
    相关资源
    最近更新 更多