阳光网驿-企业信息化交流平台【DTC零售连锁全渠道解决方案】

 找回密码
 注册

QQ登录

只需一步,快速开始

扫描二维码登录本站

手机号码,快捷登录

老司机
查看: 1416|回复: 0

[转帖] googlMap入门

[复制链接]
  • TA的每日心情
    开心
    2012-3-7 10:15
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    发表于 2012-2-1 11:52:56 | 显示全部楼层 |阅读模式
    29170510_KuZ9.jpg
    [代码] [Java]代码
    package com.android.antking.map;
    import com.google.android.maps.MapActivity;
    import com.google.android.maps.GeoPoint;
    import com.google.android.maps.MapController;
    import com.google.android.maps.MapView;
    import android.os.Bundle;
    public class MyMain extends MapActivity {
    //放大倍数
       static final int  INITIAL_ZOOM_LEVEL=12;
       //中心点
       static final int  INITIAL_LATITUDE=123465465;
       static final int  INITIAL_LONGITUDR=15634646;
       
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            MapView mapView = (MapView) findViewById(R.id.mapView);
            //enable to change the size of the map
            mapView.setBuiltInZoomControls(true);
            //设置Zoom 大小和地图的中心点
            MapController mc = mapView.getController();
            mc.setZoom(INITIAL_ZOOM_LEVEL);
            mc.setCenter(new GeoPoint(INITIAL_LATITUDE,INITIAL_LONGITUDR));
            
        }
    @Override
    protected boolean isRouteDisplayed() {
      // TODO Auto-generated method stub
      return false;
    }
    }
    [代码] [XML]代码
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        androidrientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello"
        />
    <com.google.android.maps.MapView
          android:id="@+id/mapView"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:enabled="true"
          android:clickable="true"
          android:apiKey="0FZLYf-YM4SRrJrJum55MeeaO4Gd_IitVFmtUeA"/>这个是自己开发的google mapApi 密钥
    </LinearLayout>
    [代码] 在这里加上google的地图包,还有Internet权限
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.antking.map"
          android:versionCode="1"
          android:versionName="1.0">
        <uses-sdk android:minSdkVersion="7" />
        <uses-permission android:name="android.permission.INTERNET"></uses-permission>
        <application android:icon="@drawable/icon" android:label="@string/app_name">
            <activity android:name=".MyMain"
                      android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <uses-library android:name="com.google.android.maps"></uses-library>
        </application>
    </manifest>


    楼主热帖
    启用邀请码注册,提高发帖质量,建设交流社区
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    快速回复 返回顶部 返回列表