小编Tau*_*lam的帖子

找出OSMdroid中的当前位置

我想找到我当前位置的地图并在我移动时通过在OSMdroid中显示一个图标来更新它.我在给出具体位置纬度和经度以及绘图图标时发现没有问题但是当我给出当前位置纬度和经度时有两个错误.

public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
    setContentView(R.layout.main);        
    mMapView = (MapView) this.findViewById(R.id.mapview);
    mMapView.setTileSource(TileSourceFactory.MAPNIK);
    mMapView.setBuiltInZoomControls(true);
    mMapView.setMultiTouchControls(true);        
    mapController = this.mMapView.getController();
    mapController.setZoom(15);

    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    criteria.setCostAllowed(true);
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    String provider = mLocMgr.getBestProvider(criteria, true);
    Location location = mLocMgr.getLastKnownLocation(provider);
    GeoPoint mypoint = new GeoPoint(location.getLatitude(), location.getLongitude()); // centre map here
    GeoPoint mypointicon = new GeoPoint(location.getLatitude()+1000, location.getLongitude()+1000); // icon goes here
    mapController.setCenter(mypoint);            
    mLocMgr = (LocationManager) getSystemService(LOCATION_SERVICE);
    mLocMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 100,
            this);        
    ArrayList<OverlayItem> items=new ArrayList<OverlayItem>();
    items.add(new OverlayItem("Here", "Sample Description", mypointicon));
    this.mMyLocationOverlay …
Run Code Online (Sandbox Code Playgroud)

android osmdroid

4
推荐指数
1
解决办法
1万
查看次数

在opengl android中绘制矩形

我正在尝试使用android opengl绘制一个矩形.矩形将在彩色背景中形成.运行代码后,我可以看到背景但内部没有矩形.

public void onDrawFrame(GL10 gl) 
{
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);        
    gl.glClearColor(0.4f, 0.5f, 0.6f, 0.5f);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);       
    float[] vertices=
    {
            -1.0f, 1.0f, 0.0f, 
            -1.0f, -1.0f, 0.0f,
            1.0f, -1.0f, 0.0f, 
            1.0f, 1.0f, 0.0f,               
    };
    short[] indices = { 0, 1, 2, 0, 2, 3 };     
    ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
    vbb.order(ByteOrder.nativeOrder());
    FloatBuffer vertexBuffer = vbb.asFloatBuffer();
    vertexBuffer.put(vertices);
    vertexBuffer.position(0);       
    ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2);
    ibb.order(ByteOrder.nativeOrder());
    ShortBuffer indexBuffer = ibb.asShortBuffer();
    indexBuffer.put(indices);
    indexBuffer.position(0);
    gl.glFrontFace(GL10.GL_CCW);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glCullFace(GL10.GL_BACK);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);       
    gl.glColor4f(0.5f, 0.3f, 0.3f, 0.7f);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); …
Run Code Online (Sandbox Code Playgroud)

android opengl-es

0
推荐指数
1
解决办法
1万
查看次数

在java中从object转换为char

在我的一个问题中,我得到RuntimeException,因为有必要将对象转换为char.I尝试通过使用charValueOf()方法来获取对象的原始值但不能这样做.这是我的代码.....

while ((stack.size() > 0) && (stack.peek() != '('))
{
    if (ComparePrecedence(stack.peek(), infix[i]))
    {
    }
}
boolean ComparePrecedence(char top, char p_2)
{
}
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?谢谢..

java stack

-2
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×2

java ×1

opengl-es ×1

osmdroid ×1

stack ×1