- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的网站上,我有一张指向我公司位置的嵌入式 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
<uses-permission android:name="android.permission.INTERNET"/>
还要检查 WIFI 权限等..
关于javascript - 谷歌地图嵌入 : Turn iFrame into a link in iOS/Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19697876/
我是一名优秀的程序员,十分优秀!