我要在百度android地图上画1千多个点,全部画的话会很卡,所以要循环判断各点有没超出屏幕范围,大概代码如下: for(int i=0;i<jarry.length();i++){
try {
if(Double.parseDouble(jarry.getJSONObject(i).getString("w"))<24.811905 && Double.parseDouble(jarry.getJSONObject(i).getString("j"))<113.594293)
{
mMapView.getOverlays().add(new OverItemT(er, this,jarry.getJSONObject(i).getString("j"),jarry.getJSONObject(i).getString("w"),jarry.getJSONObject(i).getString("gjxname"),jarry.getJSONObject(i).getString("Content")));
}
} catch (JSONException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
} 问题是怎么获取屏幕经纬范围,上面的数字是我自己写上去的,每个点怎么判断有没超出屏幕?求好心人提供代码,谢谢了
try {
if(Double.parseDouble(jarry.getJSONObject(i).getString("w"))<24.811905 && Double.parseDouble(jarry.getJSONObject(i).getString("j"))<113.594293)
{
mMapView.getOverlays().add(new OverItemT(er, this,jarry.getJSONObject(i).getString("j"),jarry.getJSONObject(i).getString("w"),jarry.getJSONObject(i).getString("gjxname"),jarry.getJSONObject(i).getString("Content")));
}
} catch (JSONException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
} 问题是怎么获取屏幕经纬范围,上面的数字是我自己写上去的,每个点怎么判断有没超出屏幕?求好心人提供代码,谢谢了
解决方案 »
- xmppconnection中login登陆问题
- Android的Tab选项卡中Activity跳转的问题
- 关于android中 关闭程序 exit 和finish 的区别是什么?
- EditText控件多行问题
- JNI例子碰到的问题:System.loadLibrary失败
- 从内存卡读取图片,放到list里面,再放进adapte里面出错啦
- andriod 做个查阅WORD ,哪位高手指点一下
- eclipse今天突然变回最原始的状态了
- Android出现闪退:捕获异常E/MPlugin: Unsupported class: com.mediatek.common.telephony.IOnl
- 13:16 Emulator: Warning: Quick Boot / Snapshots not supported on this machine. A
- Android:"图形控件以及方法"的自动化测试框架,请教,急~
- 如何判断animationdrawable播放结束呢
public void draw(Canvas canvas, MapView mapView, boolean shadow) { // Projection接口用于屏幕像素坐标和经纬度坐标之间的变换
Projection projection = mapView.getProjection();
int width=canvas.getWidth();//获取屏幕宽度
int height=canvas.getHeight();//获取屏幕高度
for (int index = size() - 1; index >= 0; index--) { // 遍历mGeoList
OverlayItem overLayItem = getItem(index); // 得到给定索引的item String title = overLayItem.getTitle();
// 把经纬度变换到相对于MapView左上角的屏幕像素坐标
Point point = projection.toPixels(overLayItem.getPoint(), null);
if(point.x>0 && point.x<width && point.y>0 && point.y<height)//判断有没超出屏幕
{
// 可在此处添加您的绘制代码
Paint paintText = new Paint();
paintText.setColor(Color.BLACK);
paintText.setTextSize(15);
paintText.setTypeface(Typeface.DEFAULT_BOLD);
canvas.drawText(title, point.x-30, point.y+10, paintText); // 绘制文本
}
} super.draw(canvas, mapView, shadow);
//调整一个drawable边界,使得(0,0)是这个drawable底部最后一行中心的一个像素
boundCenterBottom(er);
}
public void draw(Canvas canvas, MapView mapView, boolean shadow) { // Projection接口用于屏幕像素坐标和经纬度坐标之间的变换
Projection projection = mapView.getProjection();
int width=canvas.getWidth();//获取屏幕宽度
int height=canvas.getHeight();//获取屏幕高度
for (int index = size() - 1; index >= 0; index--) { // 遍历mGeoList
OverlayItem overLayItem = getItem(index); // 得到给定索引的item String title = overLayItem.getTitle();
// 把经纬度变换到相对于MapView左上角的屏幕像素坐标
Point point = projection.toPixels(overLayItem.getPoint(), null);
if(point.x>0 && point.x<width && point.y>0 && point.y<height)//判断有没超出屏幕
{
// 可在此处添加您的绘制代码
Paint paintText = new Paint();
paintText.setColor(Color.BLACK);
paintText.setTextSize(15);
paintText.setTypeface(Typeface.DEFAULT_BOLD);
canvas.drawText(title, point.x-30, point.y+10, paintText); // 绘制文本
}
} super.draw(canvas, mapView, shadow);
//调整一个drawable边界,使得(0,0)是这个drawable底部最后一行中心的一个像素
boundCenterBottom(er);
}
路线查询