- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
请帮助我进行android编程。我正在制作一个 android mapsforge 应用程序,并希望使用 Mysql
在 Android Mapsforge map 上添加多个标记。我的数据位于数据库 Mysql 中,我正在使用 php 获取 Json。它正在工作,但问题是添加标记。这是我的代码:
public void friend_finder(){
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://fifauz.com/selectall.php");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
Log.e("log_tag", "connection success ");
Toast.makeText(getApplicationContext(), "Connected", Toast.LENGTH_SHORT).show();
} catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
Toast.makeText(getApplicationContext(), "Connection fail", Toast.LENGTH_SHORT).show();
}
//convert response to string
try{ BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
Intent i = new Intent(getBaseContext(),MainActivity.class);
startActivity(i);
}
is.close();
result=sb.toString();
}
catch(Exception e)
{
Log.e("log_tag", "Error converting result "+e.toString());
}
try {
JSONArray jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
String name = json_data.getString("Name");
//Double lati = json_data.getDouble("latitude");
// Double longi = json_data.getDouble("longitude");
String lati = json_data.getString("Lati");
String longi = json_data.getString("Long");
String s = name + lati + longi;
double lati_d = Double.valueOf(lati.trim()).doubleValue();
double longi_d = Double.valueOf(longi.trim()).doubleValue();
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
ListOverlay listOverlay = new ListOverlay();
GeoPoint currentLocation = new GeoPoint(lati_d,longi_d);
//String marker;
//String m = marker + String.valueOf(i);
Marker marker = createMarker(R.drawable.person, currentLocation);
List<OverlayItem> overlayItems = listOverlay.getOverlayItems();
overlayItems.add(marker);
mapView.getOverlays().add(listOverlay);
}
} catch (Exception e)
{
Log.e("log_tag", "Error converting result "+e.toString());
}
{
// TODO: handle exception
}
}
private Marker createMarker(int resourceIdentifier, GeoPoint geoPoint) {
Drawable drawable = getResources().getDrawable(resourceIdentifier);
return new Marker(geoPoint, Marker.boundCenterBottom(drawable));
}
最佳答案
您也可以通过这种方式在 mapsforge map 中添加标记。
private void createPositionMarker(double paramDouble1, double paramDouble2)
final LatLong localLatLong = new LatLong(paramDouble1, paramDouble2);
TappableMarker positionmarker = new TappableMarker(R.drawable.destination, localLatLong);
mapView.getLayerManager().getLayers().add(positionmarker);
}
private class TappableMarker extends Marker{
public TappableMarker(int icon, LatLong localLatLong) {
super(localLatLong,AndroidGraphicFactory.convertToBitmap(MainActivity.this.getApplicationContext().getResources().getDrawable(icon)),
1*(AndroidGraphicFactory.convertToBitmap(MainActivity.this.getApplicationContext().getResources().getDrawable(icon)).getWidth())/2,
-1*(AndroidGraphicFactory.convertToBitmap(MainActivity.this.getApplicationContext().getResources().getDrawable(icon)).getHeight())/2);
}
}
关于java - 在 Android Mapsforge map 上添加多个标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24027943/
我想在运行时向 MapsForge 添加一些 Overlay 项目;我可以成功添加它们,但它们只有在我移动或缩放 map 后才会出现。实际上应该如此,因为在每次移动或缩放时,MapsForge 都会通
我可以让 Mapsforge lib 0.30 在 Android 上运行,我真的很满意。我遇到的问题是我无法以正确的方式添加自定义可绘制对象。当我添加要绘制的 drawable 时,drawable
MapsForge map 是否存在 zoomToSpan 方法?如果不存在,我该如何实现?有没有一些代码示例或算法描述? 提前致谢 最佳答案 您可以使用以下方法扩展 MapView(MapsForg
我目前正在使用 mapsforge ( https://github.com/mapsforge/mapsforge/ ) 开发原生安卓应用程序。我可以使用单个国家/地区的离线 map ,但稍后需要有
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
我正在为滑雪者和单板滑雪者开发一款 Android 应用程序,它可以将用户从一个点导航到另一个点。 为了显示 map ,我使用 Mapsforge-Version 0.4.0。 我在 map 上添加了
我正在尝试安装用于渗透的mapsforge-mapwriter-plugin,但我无法让它工作。 我尝试了普通的基于 shell 的版本和页面上提到的方法:“http://code.google.co
我正在尝试创建一个 mapsforge 离线 map 应用程序。我遵循了指南或那里的网站下面是我的代码的快照 但是当我运行这个应用程序时,应用程序崩溃了。 logcat 如下。 但是,如果我在 mai
我关注 mapsforge 库有一段时间了,我喜欢这个库的工作方式。 在我的项目中,我需要不同类型的标记。一种类型应该在点击时显示一个关于标记的对话框,而另一种类型应该在点击时为标记的坐标干杯。
我正在尝试使用 Mapsforge 在我的 Android 应用程序中绘制一条简单的路线。我按照一个示例创建了单点 OverlayItems。但是当我尝试绘制路线时,我在 map 上看不到任何东西。有
我知道这里有一些针对 Mapsforge fragment 的补丁:https://code.google.com/p/mapsforge/issues/detail?id=177 .但是我不确定如何
我对使用库有点陌生,想在这里寻求一些基本帮助。 我一直在尝试在这里使用 Mapsforge 的 .jar 库:https://code.google.com/p/mapsforge/downloads
我读过 mapsforge wiki它有一个示例页面“/trunk/Applications/Android/Samples”。 It现在好像死了 我在哪里可以得到它? 最佳答案 您可以在 here
我一直在尝试运行 mapsforge 项目提供的一些应用程序。我按照此处给出的说明进行操作: ( http://code.google.com/p/mapsforge/wiki/GettingStar
请帮助我进行android编程。我正在制作一个 android mapsforge 应用程序,并希望使用 Mysql 在 Android Mapsforge map 上添加多个标记。我的数据位于数据库
我从 mapsforge 服务器下载了一个 map 文件 (.map),现在我该如何编辑或向该文件添加一些信息? 例如我想更改一些街道名称 最佳答案 如果此文件遵循OSM XML schema那么你可
我的 iPhone 应用程序需要一些框架,它使用 map 。现在这些 map 是光栅图像,我想通过制作矢量 map 来优化我的应用程序。我知道我的 Android 开发同事为此目的使用了 Mapsfo
我使用 MapsForge 0.8在我的 Android 应用中显示 map 。当使用在线图 block (只是位图而不是可以在运行时渲染器中调整的 vector 数据)时, map 在我的高分辨率设
我需要在我的 Android Studio 应用中使用 Mapsforge(离线 map )。我已经导入了这些库: mapsforge-core-0.4.0.jar mapsforge-map-0.4
我正在尝试运行 mapsforge 项目中最简单的 map 查看器示例: A very basic Android app example - GitHub使用 Android Studio。 在应用
我是一名优秀的程序员,十分优秀!