【转】Android Google Map API使用的八个步骤

Android Google Map API使用的八个步骤

本系列教程将分为两部分,第一部分是指导用户使用Mapview控件进行编程,其中包括了如何获得Google Map API,如何使用该API进行简单的开发,如何获得用户当前所在的位置。第二部分则包括如何在地图上,用第三方的组件库,实现气球式显示若干指定位置的功能。

  步骤1 创建新的Android 工程

  首先打开eclipse新建立一个Android 工程,其中相关参数设置如下:

  Project name:MallFinder

  Build Target: Google APIs Platform – 2.1 API Level 7

  Application Name: Mall Finder

  Package Name: com.shawnbe.mallfinder

  Create Activity: MallFinderActivity

  MinimumSDK: 7

  如下图所示:

  步骤2 注册Google Map API key

  由于在使用google map的时候,需要使用google map api的key,因此需要先注册一个开发者key,可以到如下地址进行注册:http://code.google.com/android/add-ons/google-apis/mapkey.html ,其中需要我们先产生开发期间的md5 密纹才能完成注册,因此我们先学习如何生成一个MD5密纹。

  我们需要使用keytool工具,不使用传统的命令行方式下那枯燥的证书签名生成办法,而是直接在eclipse下通过插件进行完成,详细见步骤3

  步骤3 安装keytool插件

  在eclipse的Help菜单中,如下图,选择安装新软件:

  在安装地址中输入如下地址:http://www.keytool.sourceforge.net/update  ,如下图

  接下来会加载相关的安装程序,并显示用户协议,选择接受所有用户协议后进行安装,安装成功后重新启动eclipse即可生效。

  步骤4 产生开发期间的MD5密钥

  在重新启动eclipse后,会发现工具栏多了如下图的keytool菜单

  现在,我们打开debug.keystore,注意其位置回因操作系统不同而有不同

  Windows Vista : C:\Users\\.android\debug.keystore

  Windows XP : C:\Documents and Settings\\.android\debug.keystore

  OS X 和 Linux : ~/.android/debug.keystore

  点keytool菜单中,选择open keystore,根据提示,选择当前系统所在的debug.keystore位置并打开,如下图,

  其中,输入密码默认为android即可,并点Load加载。之后会在eclipse中出现新的keytool的视图,如下图所示:

  双击打开androiddebugkey,复制其md5密纹,然后访问页面

  http://code.google.com/android/maps-api-signup.html ,接受其协议,将md5密纹复制进去,再点Generate API Key,即产生google map的api key,记得保存好这个KEY,在接下来的步骤中要使用。

  步骤5 增加MapView控件

  接下来,我们可以往布局文件中增加MapView控件。我们在main.xml中添加如下代码:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" > 
    <FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"> 
        <com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="你的GOOGLE MAP API KEY "/> 
    </FrameLayout> 
</LinearLayout>

  在这个控件中,请注意要在android:apiKey的位置填入刚申请的google map api key。

  步骤6 设置相关的权限

  由于我们的应用需要调用Google Map的数据,以及通过手机的GPS获得相关的其他地理位置数据,因此我们必须在Android的Manifest文件中进行权限的设置。

  我们打开AndroidManifest.xml文件,然后增加如下代码所示的权限设置,注意添加在标签后,但要在标签前。

<uses-feature android:name="android.hardware.location.gps"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET"/>

  在这里,我们分别调用了gps位置服务权限,使用互联网的权限以及使用最佳位置查找的权限(FINE_LOCATION)。在本文中,其实没用到FINE_LOCATION,但只是告诉开发者可以调整使用不同的地理位置提供者(providers)以提供准确的位置服务,如果要有比较精确的地理位置服务,那么可以设置android.permisson.ACCESS_FINE_LOCATION服务。要注意的是在开发中,不要过多引用一些不需要使用的权限设置,否则会给用户带来担忧安全等问题。要是只想调用一般的位置服务,可以使用普通的android.permission.ACCESS_COARSE_LOCATION权限。

  为了在应用中使用Google Map,需要在Manifest文件中包含相关的类库文件,所以加入如下代码:

<uses-library android:required="true" android:name="com.google.android.maps" />

  为了视觉的美观,我们把标题栏也去掉,以便留给地图更大的空间,所以设置为

  android:theme="@android:style/Theme.NoTitleBar"

  下面是完整的Manifest文件代码:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.shawnbe.mallfinder"
    android:versionCode="1"
    android:versionName="1.0" > 
    <uses-sdk android:minSdkVersion="7" /> 
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar"> 
        <activity
            android:label="@string/app_name"
            android:name=".MallFinderActivity" > 
            <intent-filter > 
                <action android:name="android.intent.action.MAIN" /> 
  
                <category android:name="android.intent.category.LAUNCHER" /> 
            </intent-filter> 
        </activity> 
        <uses-library android:required="true" android:name="com.google.android.maps" /> 
    </application> 
    <uses-feature android:name="android.hardware.location.gps"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
</manifest>

  步骤7 设置MapView

  下面对主activity程序(MallFinderActivity.java)进行修改,首先让其继承MapActivity类,如下:

  public class MallFinderActivity extends MapActivity {

  由于继承了MapActivity类,因此必须实现isRouteDisplayed方法,这个方法是用来做路线导航用的,这里我们不需要,因此只需要简单返回false即可:

  @Override

  protected boolean isRouteDisplayed() {

  // TODO Auto-generated method stub

  return false;

  }

  接下来我们就可以声明MapController控件,并对其进行相关属性的设置了,首先是声明控件

  private MapController mapController;

  private MapView mapView;

  并在oncreate方法中进行属性设置如下:

mapView = (MapView)findViewById(R.id.mapView); 
mapView.setBuiltInZoomControls(true); 
mapView.setSatellite(false); 
mapView.setStreetView(true); 
mapController = mapView.getController(); 
mapController.setZoom(13);

  在上面的代码中,设置了地图显示的方式为街道模式(通过设置mapview的setStreetView属性值为true),并且通过mapView.setBuiltInZoomControls(true); 使用了系统内置的放大缩小功能,并设置了地图的放大缩小倍数为13。

  这个时候我们就可以选择运行应用,看下是否符合我们的初步预期效果,运行后效果如下图:

  步骤8 获得当前所在位置

  在LBS应用中,十分重要的工作是要获得当前设备所在的位置,这个可以使用locationManager类实现,在获得当前位置的时候是需要花费一些时间的。我们继续声明两个参数变量如下:

  private LocationManager locationManager;

  private GeoPoint currentLocation;

  分别声明了LocationManager类的实例和GeoPoint类的实例(用于下文中的经纬度的计算)。

  再增加如下几个方法:

public void getLastLocation(){ 
    String provider = getBestProvider(); 
    currentLocation = locationManager.getLastKnownLocation(provider); 
    if(currentLocation != null){ 
        setCurrentLocation(currentLocation); 
    } 
    else
    { 
        Toast.makeText(this, "Location not yet acquired", Toast.LENGTH_LONG).show(); 
    } 

  
public void animateToCurrentLocation(){ 
    if(currentPoint!=null){ 
        mapController.animateTo(currentPoint); 
    } 

  
public String getBestProvider(){ 
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
    Criteria criteria = new Criteria(); 
    criteria.setPowerRequirement(Criteria.NO_REQUIREMENT); 
    criteria.setAccuracy(Criteria.NO_REQUIREMENT); 
    String bestProvider = locationManager.getBestProvider(criteria, true); 
    return bestProvider; 

  
public void setCurrentLocation(Location location){ 
    int currLatitude = (int) (location.getLatitude()*1E6); 
    int currLongitude = (int) (location.getLongitude()*1E6); 
    currentLocation = new GeoPoint(currLatitude,currLongitude); 
  
    currentLocation = new Location(""); 
    currentLocation.setLatitude(currentPoint.getLatitudeE6() / 1e6); 
    currentLocation.setLongitude(currentPoint.getLongitudeE6() / 1e6); 
}

  并且在oncreate方法中,添加对以上方法的调用代码如下:

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    mapView = (MapView)findViewById(R.id.mapView); 
    mapView.setBuiltInZoomControls(true); 
    mapView.setSatellite(false); 
    mapView.setStreetView(true); 
    mapController = mapView.getController(); 
    mapController.setZoom(13); 
    getLastLocation(); 
    animateToCurrentLocation(); 
}

  首先,在getLastLocation这个方法中,创建了locationManager类的实例并且根据设置的条件返回一个合适的地理位置提供方法。在这里,我们并没有指定对地理位置提供者的查询条件,在实际应用中,开发者可以通过设置criteria.setAccuracy()和criteria.setPowerRequirement()方法进行查找。如果要使用最精确的provider的话,可以设置使用ACCURACY_FINE方法进行搜索,如下代码所示:

  criteria.setAccuracy(Criteria.ACCURACY_FINE);

  在本文中之所以不选择使用最准确的位置provider主要是因为是没在室外进行测试,都是在室内调试程序,建议开发完后换成GPS模式provider到室外进行调试那样将看到很好的效果。

  接下来代码中使用 currentLocation = locationManager.getLastKnownLocation(provider); 一句,获得最新的位置信息,并且在setCurrentLocation方法中,对通过prodiver获得的地理位置信息Location对象进行经纬度的转换为GeoPoint对象。然后调用animateToCurrentLocation方法,将地图的中心点定位到我们当前的位置上去。

  此外,由于我们的位置是会发生变化的,所以需要使用location 监听器去检测我们的位置变化,这时需要实现locationListener接口,如下所示:

  public class MallFinderActivity extends MapActivity implements LocationListener{

  同时我们需要实现LocationListener类的以下几个方法:

@Override
public void onLocationChanged(Location arg0) { 
    // TODO Auto-generated method stub 

  
@Override
public void onProviderDisabled(String arg0) { 
    // TODO Auto-generated method stub 

  
@Override
public void onProviderEnabled(String arg0) { 
    // TODO Auto-generated method stub 

  
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) { 
    // TODO Auto-generated method stub 
}

  其中这里我们关心的是需要实现onLocationChanged方法,这里我们调用之前编写好的setlocation方法,获得当前的最新位置,如下:

@Override
public void onLocationChanged(Location newLocation) { 
    // TODO Auto-generated method stub 
    setCurrentLocation(newLocation); 
}

  为了完善程序,在程序处在onResume及onPause状态下都能及时更新地理位置信息以及取消更新,加上如下代码:

@Override
protected void onResume() { 
    super.onResume(); 
    locationManager.requestLocationUpdates(getBestProvider(), 1000, 1, this); 

  
@Override
protected void onPause() { 
    super.onPause(); 
    locationManager.removeUpdates(this); 
}

  小结

  在本系列的第一讲中,分步讲解了如何注册Google API KEY以及Mapview控件基本方法的使用,还有让读者了解到使用google map的初步步骤,在下一讲中,将指导读者如何对地图上的位置进行标注。

本系列教程将分为两部分,第一部分是指导用户使用Mapview控件进行编程,其中包括了如何获得Google Map API,如何使用该API进行简单的开发,如何获得用户当前所在的位置。第二部分则包括如何在地图上,用第三方的组件库,实现气球式显示若干指定位置的功能。

  步骤1 创建新的Android 工程

  首先打开eclipse新建立一个Android 工程,其中相关参数设置如下:

  Project name:MallFinder

  Build Target: Google APIs Platform – 2.1 API Level 7

  Application Name: Mall Finder

  Package Name: com.shawnbe.mallfinder

  Create Activity: MallFinderActivity

  MinimumSDK: 7

  如下图所示:

  步骤2 注册Google Map API key

  由于在使用google map的时候,需要使用google map api的key,因此需要先注册一个开发者key,可以到如下地址进行注册:http://code.google.com/android/add-ons/google-apis/mapkey.html ,其中需要我们先产生开发期间的md5 密纹才能完成注册,因此我们先学习如何生成一个MD5密纹。

  我们需要使用keytool工具,不使用传统的命令行方式下那枯燥的证书签名生成办法,而是直接在eclipse下通过插件进行完成,详细见步骤3

  步骤3 安装keytool插件

  在eclipse的Help菜单中,如下图,选择安装新软件:

  在安装地址中输入如下地址:http://www.keytool.sourceforge.net/update  ,如下图

  接下来会加载相关的安装程序,并显示用户协议,选择接受所有用户协议后进行安装,安装成功后重新启动eclipse即可生效。

  步骤4 产生开发期间的MD5密钥

  在重新启动eclipse后,会发现工具栏多了如下图的keytool菜单

  现在,我们打开debug.keystore,注意其位置回因操作系统不同而有不同

  Windows Vista : C:\Users\\.android\debug.keystore

  Windows XP : C:\Documents and Settings\\.android\debug.keystore

  OS X 和 Linux : ~/.android/debug.keystore

  点keytool菜单中,选择open keystore,根据提示,选择当前系统所在的debug.keystore位置并打开,如下图,

  其中,输入密码默认为android即可,并点Load加载。之后会在eclipse中出现新的keytool的视图,如下图所示:

  双击打开androiddebugkey,复制其md5密纹,然后访问页面

  http://code.google.com/android/maps-api-signup.html ,接受其协议,将md5密纹复制进去,再点Generate API Key,即产生google map的api key,记得保存好这个KEY,在接下来的步骤中要使用。

  步骤5 增加MapView控件

  接下来,我们可以往布局文件中增加MapView控件。我们在main.xml中添加如下代码:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" > 
    <FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"> 
        <com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="你的GOOGLE MAP API KEY "/> 
    </FrameLayout> 
</LinearLayout>

  在这个控件中,请注意要在android:apiKey的位置填入刚申请的google map api key。

  步骤6 设置相关的权限

  由于我们的应用需要调用Google Map的数据,以及通过手机的GPS获得相关的其他地理位置数据,因此我们必须在Android的Manifest文件中进行权限的设置。

  我们打开AndroidManifest.xml文件,然后增加如下代码所示的权限设置,注意添加在标签后,但要在标签前。

<uses-feature android:name="android.hardware.location.gps"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET"/>

  在这里,我们分别调用了gps位置服务权限,使用互联网的权限以及使用最佳位置查找的权限(FINE_LOCATION)。在本文中,其实没用到FINE_LOCATION,但只是告诉开发者可以调整使用不同的地理位置提供者(providers)以提供准确的位置服务,如果要有比较精确的地理位置服务,那么可以设置android.permisson.ACCESS_FINE_LOCATION服务。要注意的是在开发中,不要过多引用一些不需要使用的权限设置,否则会给用户带来担忧安全等问题。要是只想调用一般的位置服务,可以使用普通的android.permission.ACCESS_COARSE_LOCATION权限。

  为了在应用中使用Google Map,需要在Manifest文件中包含相关的类库文件,所以加入如下代码:

<uses-library android:required="true" android:name="com.google.android.maps" />

  为了视觉的美观,我们把标题栏也去掉,以便留给地图更大的空间,所以设置为

  android:theme="@android:style/Theme.NoTitleBar"

  下面是完整的Manifest文件代码:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.shawnbe.mallfinder"
    android:versionCode="1"
    android:versionName="1.0" > 
    <uses-sdk android:minSdkVersion="7" /> 
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar"> 
        <activity
            android:label="@string/app_name"
            android:name=".MallFinderActivity" > 
            <intent-filter > 
                <action android:name="android.intent.action.MAIN" /> 
  
                <category android:name="android.intent.category.LAUNCHER" /> 
            </intent-filter> 
        </activity> 
        <uses-library android:required="true" android:name="com.google.android.maps" /> 
    </application> 
    <uses-feature android:name="android.hardware.location.gps"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
</manifest>

  步骤7 设置MapView

  下面对主activity程序(MallFinderActivity.java)进行修改,首先让其继承MapActivity类,如下:

  public class MallFinderActivity extends MapActivity {

  由于继承了MapActivity类,因此必须实现isRouteDisplayed方法,这个方法是用来做路线导航用的,这里我们不需要,因此只需要简单返回false即可:

  @Override

  protected boolean isRouteDisplayed() {

  // TODO Auto-generated method stub

  return false;

  }

  接下来我们就可以声明MapController控件,并对其进行相关属性的设置了,首先是声明控件

  private MapController mapController;

  private MapView mapView;

  并在oncreate方法中进行属性设置如下:

mapView = (MapView)findViewById(R.id.mapView); 
mapView.setBuiltInZoomControls(true); 
mapView.setSatellite(false); 
mapView.setStreetView(true); 
mapController = mapView.getController(); 
mapController.setZoom(13);

  在上面的代码中,设置了地图显示的方式为街道模式(通过设置mapview的setStreetView属性值为true),并且通过mapView.setBuiltInZoomControls(true); 使用了系统内置的放大缩小功能,并设置了地图的放大缩小倍数为13。

  这个时候我们就可以选择运行应用,看下是否符合我们的初步预期效果,运行后效果如下图:

  步骤8 获得当前所在位置

  在LBS应用中,十分重要的工作是要获得当前设备所在的位置,这个可以使用locationManager类实现,在获得当前位置的时候是需要花费一些时间的。我们继续声明两个参数变量如下:

  private LocationManager locationManager;

  private GeoPoint currentLocation;

  分别声明了LocationManager类的实例和GeoPoint类的实例(用于下文中的经纬度的计算)。

  再增加如下几个方法:

public void getLastLocation(){ 
    String provider = getBestProvider(); 
    currentLocation = locationManager.getLastKnownLocation(provider); 
    if(currentLocation != null){ 
        setCurrentLocation(currentLocation); 
    } 
    else
    { 
        Toast.makeText(this, "Location not yet acquired", Toast.LENGTH_LONG).show(); 
    } 

  
public void animateToCurrentLocation(){ 
    if(currentPoint!=null){ 
        mapController.animateTo(currentPoint); 
    } 

  
public String getBestProvider(){ 
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
    Criteria criteria = new Criteria(); 
    criteria.setPowerRequirement(Criteria.NO_REQUIREMENT); 
    criteria.setAccuracy(Criteria.NO_REQUIREMENT); 
    String bestProvider = locationManager.getBestProvider(criteria, true); 
    return bestProvider; 

  
public void setCurrentLocation(Location location){ 
    int currLatitude = (int) (location.getLatitude()*1E6); 
    int currLongitude = (int) (location.getLongitude()*1E6); 
    currentLocation = new GeoPoint(currLatitude,currLongitude); 
  
    currentLocation = new Location(""); 
    currentLocation.setLatitude(currentPoint.getLatitudeE6() / 1e6); 
    currentLocation.setLongitude(currentPoint.getLongitudeE6() / 1e6); 
}

  并且在oncreate方法中,添加对以上方法的调用代码如下:

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    mapView = (MapView)findViewById(R.id.mapView); 
    mapView.setBuiltInZoomControls(true); 
    mapView.setSatellite(false); 
    mapView.setStreetView(true); 
    mapController = mapView.getController(); 
    mapController.setZoom(13); 
    getLastLocation(); 
    animateToCurrentLocation(); 
}

  首先,在getLastLocation这个方法中,创建了locationManager类的实例并且根据设置的条件返回一个合适的地理位置提供方法。在这里,我们并没有指定对地理位置提供者的查询条件,在实际应用中,开发者可以通过设置criteria.setAccuracy()和criteria.setPowerRequirement()方法进行查找。如果要使用最精确的provider的话,可以设置使用ACCURACY_FINE方法进行搜索,如下代码所示:

  criteria.setAccuracy(Criteria.ACCURACY_FINE);

  在本文中之所以不选择使用最准确的位置provider主要是因为是没在室外进行测试,都是在室内调试程序,建议开发完后换成GPS模式provider到室外进行调试那样将看到很好的效果。

  接下来代码中使用 currentLocation = locationManager.getLastKnownLocation(provider); 一句,获得最新的位置信息,并且在setCurrentLocation方法中,对通过prodiver获得的地理位置信息Location对象进行经纬度的转换为GeoPoint对象。然后调用animateToCurrentLocation方法,将地图的中心点定位到我们当前的位置上去。

  此外,由于我们的位置是会发生变化的,所以需要使用location 监听器去检测我们的位置变化,这时需要实现locationListener接口,如下所示:

  public class MallFinderActivity extends MapActivity implements LocationListener{

  同时我们需要实现LocationListener类的以下几个方法:

@Override
public void onLocationChanged(Location arg0) { 
    // TODO Auto-generated method stub 

  
@Override
public void onProviderDisabled(String arg0) { 
    // TODO Auto-generated method stub 

  
@Override
public void onProviderEnabled(String arg0) { 
    // TODO Auto-generated method stub 

  
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) { 
    // TODO Auto-generated method stub 
}

  其中这里我们关心的是需要实现onLocationChanged方法,这里我们调用之前编写好的setlocation方法,获得当前的最新位置,如下:

@Override
public void onLocationChanged(Location newLocation) { 
    // TODO Auto-generated method stub 
    setCurrentLocation(newLocation); 
}

  为了完善程序,在程序处在onResume及onPause状态下都能及时更新地理位置信息以及取消更新,加上如下代码:

@Override
protected void onResume() { 
    super.onResume(); 
    locationManager.requestLocationUpdates(getBestProvider(), 1000, 1, this); 

  
@Override
protected void onPause() { 
    super.onPause(); 
    locationManager.removeUpdates(this); 
}

  小结

  在本系列的第一讲中,分步讲解了如何注册Google API KEY以及Mapview控件基本方法的使用,还有让读者了解到使用google map的初步步骤,在下一讲中,将指导读者如何对地图上的位置进行标注。

时间: 2024-08-24 11:48:08

【转】Android Google Map API使用的八个步骤的相关文章

开发Android Map程序 如何获取 apikey (Google Map API v2)

1. 在Eclise --> preference --> android --> bulid 能够看到缺省的debug keystore:注意,最新版本的Android Eclipse中无需再自己产生MD5 和 SHA1 2. 登录Google网站账户后转到如下网址 https://console.developers.google.com/project/apps~soft-edu/apiui/api?authuser=0:在该页面中点击APIs然后将Google Maps Andr

Android Google Map v2具体解释:开发环境配置

Android Google Map v2具体解释:开发环境配置                                       --转载请注明出处:coder-pig 说在前面: 说到地图定位,如今越来越多的社交app都增加了地图和定位的功能模块,用户非常多的时候 也会用到这些东东,比方,到外面吃饭,次次吃饭前都要拍下照片发到朋友圈,定个位,然后发条说说, 炫耀一下自己今天吃了什么高大上的东东,炫耀和攀比心理我懂,只是,一次下班去吃饭,看到一妹子 吃饭,拍照+发朋友圈,足足用了大概

Android Google Map v2详解之:开发环境配置

Android Google Map v2详解之:开发环境配置                                       --转载请注明出处:coder-pig 说在前面: 说到地图定位,现在越来越多的社交app都加入了地图和定位的功能模块,用户很多的时候 也会用到这些东东,比如,到外面吃饭,次次吃饭前都要拍下照片发到朋友圈,定个位,然后发条说说, 炫耀一下自己今天吃了什么高大上的东东,炫耀和攀比心理我懂,不过,一次下班去吃饭,看到一妹子 吃饭,拍照+发朋友圈,足足用了大概20

如何将经纬度利用Google Map API显示C# VS2005 Sample Code

原文 如何将经纬度利用Google Map API显示C# VS2005 Sample Code 日前写了一篇如何用GPS抓取目前所在,并回传至资料库储存,这篇将会利用这些回报的资料,将它显示在地图上,这个做法有两种,最简单的就是直接传值到Google Maps上. 举例来说,当我们知道经纬度后,只要将数据套到以下网址即可. http://maps.google.com/maps?q=25.048346%2c121.516396 在参数q=后面,就可以加上经纬度了. 25.048346是Lati

google map api v3

<!DOCTYPE html> <html> <head> <script type="text/javascript"> function killerrors() { return true; } window.onerror = killerrors; </script> <meta name="viewport" content="initial-scale=1.0, user-sc

基于HTML5的Geolocation获取地理位置,配合Google Map API反向地址解析(获取用户真实地址)

html 1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 <title>Geolocation获取地理位置,配合Google Map API

Java 调用Google Map Api解析地址,解析经纬度实例

Java 调用Google Map Api解析地址,解析经纬度实例 使用google地图的反向地址解析功能,提供一个经纬度得到对应地址,或者给出模糊地址,得到经纬度,放在java后台代码中处理,这个使用的是Google的地理编码服务.一般而言数据量不大的情况使用是不限制的.按照Google官方说法是连续90天请求地理编码服务次数超过2000次就会受到限制,因此可以将这些解析好的地址放在Database中,这样可以避免重复请求同一个地址. JAVA Code: /* * System Abbrev

Google Map API Version3 :代码添加和删除marker标记

转自:http://blog.sina.com.cn/s/blog_4cdc44df0100u80h.html Google Map API Version3 教程:在地图 通过代添加和删除mark标记 lat = 23.14746; lng = 113.34175376; var myLatLng = new google.maps.LatLng(lat, lng); var myOptions = { zoom: 15, center: myLatLng, mapTypeId: google

Google Map API V3开发(2)

3 Google Map API 简介 Google 地图 API 免费提供给用户并且适用于所有网站.Google 地图 API 使您能够使用 JavaScript 将 Google地图嵌入自己的网页中.API 提供了大量实用工具用以处理地图(正如 http://ditu.google.com 网页上的地图),并通过各种服务向地图添加内容,从而使您能够在您的网站上创建功能强大的地图应用程序. 4 帮助资源 ?Google Maps JavaScript API v3 ?中文页面:https://