生成地图标记

时间:2012-04-19 15:47:45

标签: java android google-maps

嗨我制作了一个带有少量pinOverlays的小地图应用程序。当引脚不在初始屏幕上时问题就出现了,所以应用程序从不绘制它们。

例如,如果我在animateTO(point1)中看不到point3和point2,那么它将永远不会出现在地图上,但是如果我animateTo(point2)其他引脚将永远不会出现在地图上,就像只有app一样画出可以在屏幕上看到的点。为什么会发生这种情况的任何想法?

List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.indicador_mapa);
        ContactItemizedOverlay itemizedoverlay = new ContactItemizedOverlay(drawable, this);
        //first point of location
        //oficina central 
        String coordinates[] = {"-16.50355741", "-68.13074811"};
        //prado cerca a las gradas
        String coordinates1[] ={"-16.50120505", "-68.13334501"};
        //calle murillo y oruro
        String coordinates2[] ={"-16.449587", "-68.136130"};
        //san miguel
        String coordinates3[] ={"-16.540237", "-68.078138"};

        double lat = Double.parseDouble(coordinates[0]);
        double lng = Double.parseDouble(coordinates[1]);
        double lat1 = Double.parseDouble(coordinates1[0]);
        double lng1 = Double.parseDouble(coordinates1[1]);
        double lat2 = Double.parseDouble(coordinates2[0]);
        double lng2 = Double.parseDouble(coordinates2[1]);
        double lat3 = Double.parseDouble(coordinates2[0]);
        double lng3 = Double.parseDouble(coordinates2[1]); 
        GeoPoint point = new GeoPoint((int) (lat * 1E6), 
                (int) (lng * 1E6));
        GeoPoint point1 = new GeoPoint((int) (lat1 * 1E6), 
                (int) (lng1 * 1E6));
        GeoPoint point2 = new GeoPoint((int) (lat2 * 1E6), 
                (int) (lng2 * 1E6));
        GeoPoint point3 = new GeoPoint((int) (lat3 * 1E6), 
                (int) (lng3 * 1E6));

        OverlayItem overlayitem = new OverlayItem(point, "oficina1", "Agencia calle Batallón Colorado");
        OverlayItem overlayitem1 = new OverlayItem(point1, "oficina2", "Agencia calle camacho #2135");
        OverlayItem overlayitem2 = new OverlayItem(point2, "oficina3", "agencia Calle Murillo");
        OverlayItem overlayitem3 = new OverlayItem(point3, "oficina4", "Agencia san miguel calle 21 esquina montenegro");
        //add the itemized overlay to the list of itemized overlays
        itemizedoverlay.addOverlay(overlayitem);
        itemizedoverlay.addOverlay(overlayitem1);
        itemizedoverlay.addOverlay(overlayitem2);
        itemizedoverlay.addOverlay(overlayitem3);
        mapOverlays.add(itemizedoverlay);

        mapControler = mapView.getController();
        mapControler.animateTo(point);
        mapControler.setZoom(16); 
        // MyLocationOverlay mLocationOverlay = new MyLocationOverlay(getBaseContext(), mapView);
        // mapControler.animateTo(mLocationOverlay.getMyLocation());

2 个答案:

答案 0 :(得分:1)

请参阅此博客可以帮助您:

Google Maps In Android

答案 1 :(得分:1)

请参阅此LINK,它简要说明了地图上的绘图针点。