2013-10-31 4 views
0

내 웹 사이트에는 사업장 위치에 Google지도가 내장되어 있습니다. 누군가가 아이폰 OS/Android 기기에 내 웹 사이트를 볼 때 나는 그들이지도를 클릭 할 수 있도록하고 싶습니다 그리고 그것은 URL 스키마Google지도 Embed : iOS/Android의 링크로 iFrame을 바꿉니다.

를 사용하여 기본 구글지도 앱에서 열 내 계획을 설정하는 것입니다 comgooglemaps://

iFrame을 해당 장치의 링크에 넣었지만 운이 없다.

누구든지이 작업을 수행하는 방법이나이 기능을 구현하는 방법에 대해 더 잘 알고 있습니다.

답변

0

브라우저가 certian 크기 아래에있을 때 jQuery를 사용하여 iFrame을 숨기고 정적 이미지로 바꿀 수있는 방법을 결정했습니다. 나는 그 때 간단한 문제이었다.

1

내가 가진 JSON

"GoogleMap으로"0 \ "스타일"\ FRAMEBORDER = "\"높이 = \ "450 \"폭 = \ "600 \"\의 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 = \ "국경 : 0 \"\ u003E 페이지의 \의 u003c/iframe이 \의 u003E 페이지 "

가 구문 분석 문자열에 ... 결과

문자열은 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! 1sPakistan + Lahore ! 5e0! 3m2! 1sen! 2s! 4v1395138949280 width = 600 height = 450 frameborder = 0 style = border : 0 ";

레이아웃 :

<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> 

자바 클래스 activity_main : 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. 012,319,207,562,163,749,171,321 또한 0

첵 WIFI 권한 등

0
WebView webview = (WebView) contact.findViewById(R.id.webView); 
    webview.getSettings().setJavaScriptEnabled(true); 
    webview.loadData("<iframe src=\"https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d59155.3066742403!2d82.165487!3d22.079923!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x41830cd45c4743bd!2sJD+Civil+Services+Academy!5e0!3m2!1sen!2sin!4v1497879962473\" width=\"600\" height=\"450\" frameborder=\"0\" style=\"border:0\" allowfullscreen></iframe>", "text/html", "utf-8"); 
    WebSettings webViewSettings = webview.getSettings(); 
    webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true); 
    webViewSettings.setJavaScriptEnabled(true); 
    webViewSettings.setBuiltInZoomControls(true); 
    webViewSettings.setPluginState(WebSettings.PluginState.ON); 
+0

코드 만 추가하지 마십시오. 대답을 설명하십시오 – Jens

+0

좋아요. iframe in android의 도움으로 webview에지도를 표시하기위한 코드 만 게시하십시오. –

관련 문제