Android位置和地图中的导航和搜索选项 [英] Navigation and Search option in Android Location and Map
问题描述
我正在进行applcation,我已经实现了谷歌地图..我可以在我的应用程序中调用我的当前位置..现在我有以下查询:
1)我想在我的地图中添加搜索选项..通过搜索选项我可以找到地点和东西。
2)我将如何从我当前的位置导航到我将从我的搜索结果中选择的目的地。
3)想要将标记放到我当前的位置。并想要自动缩放到我的当前位置
m没有任何想法:(。任何人都可以帮我解决这个问题???
这是我的代码:
Hi, I'm making an applcation in which i have implemented google map..m able to call current location of mine in my app..now i have following queries:
1)I want to add search option in my map..with that search option i can find places and things.
2)how will i navigate from my current location to the destination which i will select from my search result.
3) want to place marker to my current location.and want to autozoom to my current location
m not getting any idea:(.can anybody help me to solve this???
Here is my code:
package com.example.navigate;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
googleMap = ((MapFragment) getFragmentManager().
findFragmentById(R.id.map)).getMap();
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
googleMap.setMyLocationEnabled(true);
}
}
推荐答案
我想我可以帮助解决3号问题。
对于1号和2号,我也有同样的问题。
幸运的是我发现了谷歌Map Places API但无法找到导航API。
Places API: https:// developers。 google.com/places/documentation/ [ ^ ]
所以上面的API用在服务器上(你会读更多)。
问题3:
Hi,
I think I can help for the question in number 3.
For number 1 and 2, I'm also having the same problem.
Luckily I found a Google Map Places API but couldn't find a Navigation one.
Places API: https://developers.google.com/places/documentation/[^]
So the above API is used on Servers(You'll read more).
For Question number 3:
private void setUpMarker() {
GoogleMap gMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.gMap)).getMap();
LatLng NAIROBI = new LatLng(-1.283, 36.817);
Marker gMarker = gMap.addMarker(new MarkerOptions()
.position(NAIROBI)
.title("Kenya")
.snippet("Nairobi, Kenya!")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
}
然后按您的意愿调用上述方法。
如果什么都不是直的,让我知道,我会解释。
Then call the above method where you wish.
If anything isn't straight, let me know, I'll explain.
这篇关于Android位置和地图中的导航和搜索选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!