80,337
社区成员
发帖
与我相关
我的任务
分享
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(marker, 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();
}
}
@Override
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(marker);
}
@Override
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(marker);
}