我正在使用 WordPress 的自定义帖子类型插件。我添加了地理位置 map 扩展,以便在后端,客户端可以输入物理地址,然后它将输出地理坐标。这工作正常,直到我将它与 geoJson 函数一起使用来放置标记。
下面是放置标记的脚本。
var geoJson = [{
type: 'Feature',
"geometry": { "type": "Point", "coordinates": [-97.325741, 32.7423499]},
"properties": {
"image": "",
"url": "http://google.com",
"marker-symbol": "commercial",
"marker-color": "#ff793d",
"marker-size": "large"
}
}];
自定义字段应如下所示就位:
"geometry": { "type": "Point", "coordinates": [<php? the_field('map_address'); ?>]},
但是,输出的坐标的顺序与此函数所需的顺序相反。它们对于我动态使用它们的其他区域是正确的,但需要知道如何交换它们在此处输出的顺序(如果可能)。
有什么想法吗?
最佳答案
根据GeoJSON Format Specification :
Point coordinates are in x, y order (easting, northing for projected coordinates, longitude, latitude for geographic coordinates)
这意味着您希望将坐标从现有坐标切换。
"geometry": { "type": "Point", "coordinates": [32.7423499, -97.325741]}
关于php - 需要反转动态地理位置坐标以与 geoJson 脚本一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17818334/