gpt4 book ai didi

ios - 可以将位置或搜索参数传递给 comgoogleearth ://in iOS?

转载 作者:行者123 更新时间:2023-12-02 01:57:32 31 4
gpt4 key购买 nike

如果 Google 地球 应用程序安装在 iPad(使用 iOS 4.2 或 5.0.1)上,则 URL 方案链接到 comgoogleearth://

有没有办法提供参数来指定位置作为搜索或 .kml 或 .kmz 中的文件?到目前为止,我已经尝试了各种语法,但没有任何运气。

我已经知道如何在 Google map 应用程序中打开该位置 - 使用 http://maps.google.com/带有适当搜索参数的链接被“劫持”到 map 应用程序而不是网站。

如果可能的话,我希望使用 Google 地球做同样的事情。

最佳答案

并非直接否,迄今为止,Google Earth 的 Apple 应用程序协议(protocol)不支持任何类型的查询。

NSString *stringURL = @"comgoogleearth://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url]

但是,您可以在可公开访问的服务器上使用 CGI 脚本非常轻松地间接实现所需的功能。

1) 创建一个 CGI 脚本,该脚本将接受给定的纬度和经度,并使用给定的位置创建一个简单的 KmlPlacemark。

例如,在 PHP 中:

<?php
// Get the latitude and longitude from the query
if(is_numeric($_GET["lng"]) && is_numeric($_GET["lat"])) {
$lng = $_GET["lng"];
$lat = $_GET["lat"];
} else {
exit();
}

// Creates an array of strings to hold the lines of the KML file.
$kml = array('<?xml version="1.0" encoding="UTF-8"?>');
$kml[] = '<kml xmlns="http://earth.google.com/kml/2.1">';
$kml[] = ' <Document>';
$kml[] = ' <Placemark id="">';
$kml[] = ' <Point>';
$kml[] = ' <coordinates>' . $lng . ',' . $lat . '</coordinates>';
$kml[] = ' </Point>';
$kml[] = ' </Placemark>';
$kml[] = ' </Document>';
$kml[] = '</kml>';
$kmlOutput = join("\n", $kml);
header('Content-type: application/vnd.google-earth.kml+xml');
echo $kmlOutput;
?>

2) 使用我们创建的提供所需坐标的 CGI 脚本的 URL 调用 Google Earth 的 Apple 应用程序协议(protocol)。例如

comgoogleearth://www.yourserver.com/kmlScript.php?lng=53.2&lat=34.34

加载 URL 后,Google 地球应用程序将飞至该位置。

此方法可用于通过搜索(地理编码)轻松生成位置,只需稍加修改即可。

唯一的限制是IOS设备必须能够访问保存CGI脚本的服务器(无法离线工作)

关于ios - 可以将位置或搜索参数传递给 comgoogleearth ://in iOS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8330749/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com