gpt4 book ai didi

javascript - 谷歌地图嵌入 : Turn iFrame into a link in iOS/Android

转载 作者:行者123 更新时间:2023-11-28 22:23:19 25 4
gpt4 key购买 nike

在我的网站上,我有一张指向我公司位置的嵌入式 Google map 。当有人在 iOS/Android 设备上查看我的网站时,我希望他们能够单击 map 并使用 URL 架构在 native Google map 应用程序中打开 map

comgooglemaps://

我的计划是将 iFrame 变成这些设备上的链接,但我没有运气。

任何人都知道如何执行此操作或更好地了解如何实现此功能。

最佳答案

我有 JSON

"GoogleMap":"\u003ciframe src=\"https://www.google.com/maps/embed?pb=!1m16!1m12!1m3!1d434549.40374533384!2d74.24349628287739!3d31.690830957117996!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!2m1!1sPakistan+Lahore!5e0!3m2!1sen!2s!4v1395138949280\"width=\"600\"height=\"450\"frameborder=\"0\"style=\"border:0\"\u003e\u003c/iframe\u003e",

解析成字符串时,....结果

String iframe = "https://www.google.com/maps/embed?pb=!1m16!1m12!1m3!1d434549.40374533384!2d74.24349628287739!3d31.690830957117996!2m3!1f0!2f0!3f0! 3m2!1i1024!2i768!4f13.1!2m1!1s巴基斯坦+拉合尔!5e0!3m2!1sen!2s!4v1395138949280 width=600 height=450 frameborder=0 style=border:0";

布局:activity_main

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#00FF00" >

<TextView
android:id="@+id/header_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Google Map"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</RelativeLayout>

<WebView
android:id="@+id/googlemap_webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />

</LinearLayout>

Java 类:MainActivity

public class MainActivity extends Activity {

private WebView googleMapWebView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeUI();
}

/**
* This method is used to Initialize UI components
*/
private void initializeUI() {

String iframe = "<iframe src=https://www.google.com/maps/embed?pb=!1m16!1m12!1m3!1d434549.40374533384!2d74.24349628287739!3d31.690830957117996!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!2m1!1sPakistan+Lahore!5e0!3m2!1sen!2s!4v1395138949280 width=600 height=450 frameborder=0 style=border:0</iframe>";
googleMapWebView = (WebView) findViewById(R.id.googlemap_webView);
googleMapWebView.getSettings().setJavaScriptEnabled(true);
googleMapWebView.loadData(iframe, "text/html", "utf-8");
}

}

AndroidManifest.xml

  1. <uses-permission android:name="android.permission.INTERNET"/>

还要检查 WIFI 权限等..

关于javascript - 谷歌地图嵌入 : Turn iFrame into a link in iOS/Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19697876/

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