【问题标题】:Google maps geometry controls identify coordinates array谷歌地图几何控件识别坐标数组
【发布时间】:2011-03-12 10:19:57
【问题描述】:

geometry.js 页面上的 example 中,我发现 saveData 函数将“信息”保存到数组和 JSON 数据格式(不起作用),如果我发出警报(record.type);我根据我点击的对象得到“point”或“polilyne”,如果我警告record.title输出标题非常正确,但是当我警告record.coordinates时输出是未定义的......

我只需要确定保存坐标的“地点”...

谢谢, 问候

【问题讨论】:

  • 这看起来像是一个 v2 问题。您的标签不正确。

标签: json google-maps google-maps-api-3


【解决方案1】:

您可以发布指向您页面的链接吗?至于几何图形的存储位置,添加到页面的每个控件(标记、线条、多边形)都有自己的存储数组,例如来自 polygoncontrol.js

me.storage = [/*array of GeometryControls#beans#Geometry*/]

如果您查看 GeometryControls#beans 的定义,您会看到

Geometry:function(p){

    this.type = p.type;

    this.geometry = p.geometry;

    this.title = p.title || ["",""];

    this.description = p.description || ["",""];

  }

实际坐标在 GeometryControls.prototype.saveData 中被序列化

 //determine geometry type, and copy geometry appropriately

    if(record.type === "point"){

      recordJSON.coordinates.push({lat:record.geometry.getLatLng().lat(),lng:record.geometry.getLatLng().lng()});

    } else {

      var vertex;

      for(var i=0;i<record.geometry.getVertexCount();i++){

        vertex = record.geometry.getVertex(i);

        recordJSON.coordinates.push({lat:vertex.lat(),lng:vertex.lng()});

      }

    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-05
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多