2012-04-19 62 views
0

嗨我用少量pinOverlays做了一個小地圖應用程序。當引腳不在初始屏幕上時,問題就出現了,所以應用程序不會繪製它們。生成地圖標記

例如,如果我在animateTO(point1)中看不到point3和point2,那麼永遠不會出現在地圖上,但是如果我animateTo(point2)其他引腳永遠不會出現在地圖上,就像應用程序只畫出可以在屏幕上看到的點。爲什麼會發生這種情況的任何想法?

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()); 

回答

1

請參閱本LINK它在地圖上繪製pinspoints的簡要說明。

+0

感謝您的迴應。關於你的代碼,在另一個答案中,這解決了不在屏幕上的點的問題,我看到這個代碼的唯一區別是它們是從數據庫中添加的,這是你的代碼的一部分沒有提出答案。我想知道這是如何解決這種情況的,即只有初始屏幕上出現的引腳被繪製出來,如果你能解釋我多一點會很棒,我不明白。 – 2012-04-19 16:34:38

+0

在那個鏈接中,你有forloop(setoflocations)只需在你的代碼中製作地理點的數組列表,然後你可以使用它作爲循環。 – 2012-04-19 16:37:20

+0

好吧,比單獨添加地址點更簡單,這是非常棒的工作,但它不能解決我的問題,即初始屏幕之外的地址點永遠不會被繪製。 – 2012-04-19 18:42:09

1

看到這個博客可能幫助你:

Google Maps In Android

+0

謝謝,回答,其實我之前讀過這個代碼,但是我沒有看到它在初始屏幕上爲指向哪個點繪製的標記。如果這是在博客上,請告訴我在哪裏,我沒有看到任何與我的問題沒有關係 – 2012-04-19 15:58:12