开发者

Need help regarding placement of map marker

开发者 https://www.devze.com 2023-02-05 22:16 出处:网络
I need your quick assistance for the problem stated below In my android application I show a marker on specific location.

I need your quick assistance for the problem stated below

In my android application I show a marker on specific location.

Here is my code

double latitude = Double.parseDouble(this.latitude);
    double longitude = Double.parseDouble(this.longitude);



    int latitudeE6 = (int) (latitude * 1e6);
    int longitudeE6 = (int) (longitude * 1e6);


    Log.i("Latitude","String = "+this.latitude+",Double = "+latitude+", int = "+latitudeE6);
    Log.i("Longitude","String = "+this.longitude+",Double = "+longitude+", int = "+longitudeE6);


    GeoPoint point = new GeoPoint(latitudeE6, longitudeE6);
    Log.i("Point a", ""+point.getLatitudeE6()+","+point.getLongitudeE6());
    OverlayItem overlay = new OverlayItem(point, title, detail);

    Drawable drawable = mapView.getContext().getResources().getDrawable(
            R.drawable.pin);


    HelloOverlayItem helloOverLay = new HelloOverlayItem(drawable, this);
    Log.i("Point b", ""+point.getLatitudeE6()+","+point.getLongitudeE6());
    helloOverLay.addOverlay(overlay);

    mapView.getOverlays().add(helloOverLay);

    MapController controller = mapView.getController();

    Log.i("Point c", ""+point.getLatitudeE6()+","+point.getLongitudeE6());

    controller.animateTo(point);
    controller.setCenter(point);
    controller.s开发者_如何学GoetZoom(10);

I can get proper location integers in "Point C" log entry, which is not 0,0 (some where near London) But in map it always show me on 0,0 how can it be possible?? How to get rid of this??


I can't say that it's surely an answer or just a work around until it create some bug. But calling mapView.invalidate() worked. I have added this line exactly after mapView.getOverlays().add(helloOverLay); And it worked.

0

精彩评论

暂无评论...
验证码 换一张
取 消