在谷歌地图会自动添加多个geopoints和标记

编程入门 行业动态 更新时间:2024-10-28 03:21:56
本文介绍了在谷歌地图会自动添加多个geopoints和标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

时有可能使添加在地图上更自动一个的GeoPoint的?我的意思是,如果我们有很多点,在地图(超过100)增加,我们没有一个像添加它们之一:

Is it possible to make the addition of a geopoint in a map more "automatic"? I mean, if we have many points to add in the map (more than 100), we don't have to add them one by one like that:

GeoPoint point2 = new GeoPoint(microdegrees(36.86774),microdegrees(10.305302)); GeoPoint point3 = new GeoPoint(microdegrees(36.87154),microdegrees(10.341815)); GeoPoint point4 = new GeoPoint(microdegrees(36.876093),microdegrees(10.325716)); pinOverlay.addPoint(point2); pinOverlay.addPoint(point3); pinOverlay.addPoint(point4);

有没有一种方法去购买他们都在一个表,然后编译器由一个增加了他们吗?

Is there a method to stock them all in a table and then the compiler adds them one by one?

推荐答案

您会希望将它们存储在任何一个SQLite数据库或其他形式的数据存储,然后你可以拉他们,并把他们在地图上与ItemizedOverlay,看到的 谷歌地图查看 的(教程)。

You'll want to store them in either a SQLite database or some other form of data storage, and then you can pull them in and place them on the map with an ItemizedOverlay, see Google Map View (a tutorial).

创建从一个数据库游标阵列​​

Cursor cursor = mDbHelper.getItems(); cursor.moveToFirst(); List<CatchItem> catchList = new ArrayList<CatchItem>(); if (cursor != null && cursor.getCount() > 0) { for (int i = 0; i < cursor.getCount(); i++) { CatchItem item = new CatchItem(); item.Latitude = cursor.getDouble(cursor.getColumnIndex("latitude")); item.Longitude = cursor.getDouble(cursor.getColumnIndex("longitude")); catchList.add(item); cursor.moveToNext(); } }

ItemizedOverlay

List<Overlay> overlays = mMaps.getOverlays(); overlays.clear(); CatchesItemizedOverlay catchOverlays = new CatchesItemizedOverlay(getResources().getDrawable(R.drawable.map_markeroverlay_blue72), this); for (int i = 0; i < catchList.size(); i++) { double lat = catchList.get(i).Latitude; double lng = catchList.get(i).Longitude; GeoPoint geopoint = new GeoPoint((int)(lat*1E6), (int)(lng*1E6)); catchOverlays.addOverlay(new CatchOverlayItem(this, geopoint, catchList.get(i))); } overlays.add(catchOverlays);

CatchesItemizedOverlay 是我自己的扩展 ItemizedOverlay (我需要自定义的功能)。该catchList对象只是具有经度和纬度的自定义对象。

CatchesItemizedOverlay is my own extended ItemizedOverlay (I needed custom functionality). The catchList object is just a custom object that has latitude and longitude.

希望这对你的作品。

更多推荐

在谷歌地图会自动添加多个geopoints和标记

本文发布于:2023-11-16 16:05:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605781.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   标记   地图   geopoints

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!