Posts

Showing posts with the label Google地圖

Android+Google Map API v3 Geocoding(地址轉經緯度度

Image
package wells.example.googlemapexample; import android.app.Activity; import android.content.Context; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.view.View; import android.view.WindowManager; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout.LayoutParams; import android.widget.Toast; public class MainActivity extends Activity {  private static final String MAP_URL = "file:///android_asset/googleMap.html";  private WebView webView;  private EditText addressText;  private Button submit;  private boolean webviewReady = false;   @Override  /** Called when the activity is first created. */  public void onCreate(Bundle savedInstanceStat...

動態改變Google Map的大小(以高度為例)

      function resizeMap(size){//         var mid = document.getElementById('map_canvas');         mid.style.height = size + ' px ';         if(map != null) {            google.maps.event.trigger(map, 'resize');         }          }  

Android-使用webview在V3版的Google地圖GPS定位

Image
目的:透過GPS或網路定位來決定裝置目前的位置 程式執行動態畫面錄影: https://www.youtube.com/watch?v=_Bw2YP39WOw 畫面中可看到經緯度的資料約每隔一秒更新一次。 測試時必須要用GPS的模擬器播放預存的GPS記錄檔(KML)來模擬實際GPS抓到定位的資料,如下畫面: 程式要能接收GPS或網路的定位資料必須實作LocationListener介面,其中有幾個介面方法可以用在實際上的程式撰寫,像是定位資料的變化的相關方法「public void onLocationChanged(Location location」,其他像是偵測GPS裝置是否啟動或不啟動的方法。 主程式: package wells.example.googlemapexample; import android.app.Activity; import android.content.Context; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; import android.widget.EditText; public class MainActivity extends Activity implements LocationListener {  private static final String MAP_URL = "file:///android_asset/googleMap.html";  private WebView webView;  private EditText Lat...

Android-使用webview在V3版的Google地圖標註座標

Image
googlemaps.xml < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"     android:layout_width = "fill_parent"     android:layout_height = "fill_parent"     android:focusable = "true"     android:focusableInTouchMode = "true"     android:orientation = "vertical" >     < RelativeLayout         android:id = "@+id/RelativeLayout1"         android:layout_width = "fill_parent"         android:layout_height = "133dp"         android:focusable = "true"         android:focusableInTouchMode = "true" >         < TextView               android:id = "@+id/textView2"               android:layout_width = "wrap_content"             ...

Android-使用webview顯示V3版的Google地圖

Image
目的:使用Google Map API v3載入Google地圖。 專案目錄結構如下: 在assets目錄下放置專案要載入的googleMap.html, 內容如下: <!DOCTYPE html > <html>   <head>     <meta charset =" utf -8">     <title>Google Maps JavaScript API v3 Example: Marker Animations</title>     <link href ="/maps/documentation/ javascript /examples/default.css" rel =" stylesheet ">     <script src ="https://maps.googleapis.com/maps/api/js?sensor=false"></script>     <script>         var m1 = new google.maps.LatLng(24.217712, 120.580806); //弘光科技大學,台中市中棲路34號       var map;       function initialize() {         var mapOptions = {           zoom: 15,           mapTypeId: google.maps.MapTypeId.ROADMAP,           center: m1     ...

Google地圖標註與自訂圖示標註

Image
(前言 待補) 自訂標示圖案 改二個地方: 1.Map.html <script>    var m1 = new google.maps.LatLng(24.1564125, 120.6779761); //台中市北區英才路102巷61號    var m2 = new google.maps.LatLng(24.1564069, 120.676978); //台中市北區大雅路100號    var marker;    var map;    var image = 'taxi-icon.png';//image變數指向計程車圖示檔案,圖示檔案請放在相同目錄      function mark(lat, log){//標註座標函式,由C#端呼叫,傳進經度與緯度…        var m = new google.maps.LatLng(lat, log);        marker = new google.maps.Marker({          map:map, draggable:true,          position: m,          icon: image //指定標示圖案為image        }); 2.在目錄中放入圖案檔(用GOOGLE找可用的圖片檔) 參考資料: https://developers.google.com/maps/documentation/javascript/overlays#Markers [C#端程式碼] public Form1(){   InitializeComponent();   if (File.Exists(AppDomain.CurrentDomain.BaseDirectory +...