简体   繁体   English

Google使用纬度和经度将导航映射到特定位置

[英]Google maps navigation to a particular place using latitude and longitude

I am a newbie to Android development, I am working on Google maps. 我是Android开发的新手,正在使用Google地图。 I am trying to navigate to particular location by using latitude and longitude. 我试图通过使用经度和纬度导航到特定位置。 I have give required permissions in manifest file, but I couldn't do navigation, please help me. 我已在清单文件中授予了所需的权限,但是我无法导航,请帮助我。

MainActivity,java MainActivity,java

package com.examp.nowmap;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

@SuppressLint("NewApi")
public class MainActivity extends Activity {
static final LatLng GOA = new LatLng(15.193588,73.942366);
private GoogleMap mapn;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapn = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
    .getMap();
Marker hamburg = mapn.addMarker(new MarkerOptions().position(GOA)
    .title(LOCATION_SERVICE));

   mapn.moveCamera(CameraUpdateFactory.newLatLngZoom(GOA, BIND_ALLOW_OOM_MANAGEMENT));
   mapn.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
} 

manifest.xml manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examp.nowmap"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />

<permission
    android:name="com.examp.nowmap.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<uses-permission android:name="com.examp.nowmap.package.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission  android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.examp.nowmap.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBZ2omuN7djk6R8eUNLkIrn13DEvnN-q58" />

</application>
</manifest>

You do not have the permission: 您没有权限:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

This is required to access the Google servers, I'm not sure this will fix your problem entirely, but its best to follow the actual Google API V2 tutorial for android. 这是访问Google服务器所必需的,我不确定这是否可以完全解决您的问题,但是最好遵循适用于Android的实际Google API V2教程。

click this link --> https://developers.google.com/maps/documentation/android/intro 点击此链接-> https://developers.google.com/maps/documentation/android/intro

This will help you make sure you've got everything set up right. 这将帮助您确保一切设置正确。 The only other thing worth noting is make sure your working on a real device as Google maps wont work in an emulator. 唯一需要注意的另一件事是,确保您在真实设备上工作,因为Google地图不会在模拟器中工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌地图不返回经度和纬度 - Google maps not returning longitude and latitude 使用Google静态地图检索经度/纬度时出现问题 - Issue retrieving longitude/latitude using Google Static Maps 在Google地图上获取以前的相机的经度和纬度 - Getting the previous camera Latitude and Longitude on Google Maps 检索纬度和经度时 Google Maps NullPointerException - Google Maps NullPointerException while retrieving Latitude and Longitude Google Maps GPS:经度和纬度返回零 - Google maps GPS: longitude and latitude returns zero 如何使用Google Place API或任何JAVA API从URL获取经度/纬度 - How to get longitude/latitude from an URL using Google Place API or any JAVA API 如何使用纬度,经度和半径(距离)将区域划分为更小尺寸的区域,在Google中使用Java搜索API? - How to divide the region into smaller size regions using latitude, longitude and radius(distance), in Google place Search API in Java? 如何使用 Google 的 GeoCoder Java Client 获取特定地点的经度和纬度? - How can I get the longitude and latitude of a specific place using Google's GeoCoder Java Client? 如何在不使用Google地图的情况下获取特定城市或街道的经度和纬度? - How to get Latitude and Longitude for particular city or street without using google map? 要将纬度n的经度值传递给Google Maps API - To pass latitude n longitude values to Google Maps API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM