通过触摸或点按在Android Google地图上添加标记 [英] Add Marker on Android Google Map via touch or tap

查看:298
本文介绍了通过触摸或点按在Android Google地图上添加标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android Developer的初学者。我想用Google Map开发一个地图应用程序。
现在,我想通过触摸或点击地图在地图上添加标记。我不知道如何应用触摸事件在地图上放置标记。请告诉我,如果可能的话,请给我一些链接或例子。感谢您对我的英语抱歉。

I am a beginner in Android Developer. I want to develop a Map Application using Google Map. Now, I want to add marker on the map via Touch or Tap on the Map. I do not know how to apply touch event to drop the marker on the map. Please tell me and, if it is possible, please give me some links or examples. Thank you and sorry for my English.

推荐答案

此代码是成功运行我正在处理该代码,此代码适用于动态绘图

This code is Successful run I am working on that code this code is for Dynamic Draw

我认为这段代码可以帮助您更多地使用静态或动态两个地方,您可以使用
这段代码

I think this code help you more for Static or dynamic both places you can use this code

double latval = Double.parseDouble(jsonobject.getString("lat"));
double longval = Double.parseDouble(jsonobject.getString("lon"));

mMap.addMarker(new MarkerOptions()
               .position(new LatLng( latval,    longval))
               .title(jsonobject.getString("country"))
               .snippet("4 E. 28TH Street From $15 /per night")
               .rotation((float) -15.0)
               .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE))
              );

if (i == 0) {
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
                                new LatLng(latval, longval), 7));
    mMap.addCircle(new CircleOptions()
                   .center(new LatLng(latval,longval))
                   .radius(5000)
                   .strokeColor(Color.RED)
                   .fillColor(Color.RED)); 
}

这篇关于通过触摸或点按在Android Google地图上添加标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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