Google地图上的红色标记上的android自动标题 [英] android automatic title on red marker on Google Maps

查看:126
本文介绍了Google地图上的红色标记上的android自动标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个android地图应用程序,它跟踪用户位置并将其显示在地图上。我这样做是为了让一个标题你在这里出现在红色标记上。然而,它并没有出现,我必须点击红色标记。我可以点击任何红色标记,标题将移到那里并在前一个标题上消失。

我如何使它只出现在最新的红色标记(最新位置)上,并且不能被删除?向用户显示他当前的位置。

速度我把它设置为1.我不知道它是否够好。该位置停止更新,而我没有移动,但它仍然缓慢和不准确。

  public void onLocationChanged(Location myLocation){
System.out.println(speed+ myLocation.getSpeed());
if(myLocation.getSpeed()>速度)
{
//显示地图上的位置.................
//获取当前位置的纬度
double latitude = myLocation.getLatitude();
//获取当前位置的经度
double longitude = myLocation.getLongitude();
//为当前位置创建一个LatLng对象
LatLng latLng = new LatLng(纬度,经度);
//在Google Map中显示当前位置
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
//放大Google Map
googleMap.animateCamera(CameraUpdateFactory.zoomTo(20));
googleMap.addMarker(new MarkerOptions()。position(new LatLng(latitude,longitude))。snippet(You are here!)。title(You are here!));


解决方案

试试这个: b

  Marker pos = googleMap.addMarker(new MarkerOptions()。position(new LatLng(latitude,longitude))。snippet(You are here!)。标题(你在这里!)); 

而不是

  googleMap.addMarker(new MarkerOptions()。position(new LatLng(latitude,longitude))。snippet(You are here!)。 

或者
写下这个,很简单: - $ / b
$ b

  locationMarker.showInfoWindow(); 


I have a android map application where it track the user location and display it on the map. i make it so that there will be a title "you are here" that appear on top of the red marker. however, it did not appear on its own and i must tap on the red marker. and i could tap on any red marker and the title would move there and disappear on the previous one.

how do i make it so that it only appears on the latest red marker(latest location) on its own and cannot be removed?to show the user his current location.

the speed i set it at 1. i do not know whether it is good enough. the location stopped updating while i was not moving but it is still slow and inaccurate.

    public void onLocationChanged(Location myLocation) {
    System.out.println("speed " + myLocation.getSpeed());
    if(myLocation.getSpeed() > speed)
    {
        //show location on map.................
        //Get latitude of the current location
        double latitude = myLocation.getLatitude();
        //Get longitude of the current location
        double longitude = myLocation.getLongitude();
        //Create a LatLng object for the current location
        LatLng latLng = new LatLng(latitude, longitude);
        //Show the current location in Google Map
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        //Zoom in the Google Map
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(20));
        googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).snippet("You are here!").title("You are here!"));

解决方案

Try This:-

Marker pos = googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).snippet("You are here!").title("You are here!"));

instead of

   googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).snippet("You are here!").title("You are here!"));

Or Write this, it is very easy:-

locationMarker.showInfoWindow();

这篇关于Google地图上的红色标记上的android自动标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆