Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android地图上顺利填充pin?_Android_Google Maps - Fatal编程技术网

如何在Android地图上顺利填充pin?

如何在Android地图上顺利填充pin?,android,google-maps,Android,Google Maps,我在谷歌地图上用pin图像显示地点,在android中调用 放大或缩小地图时,此url将一直刷新。 我使用此代码在doInbackground的onpostExecution的AsyncTask加载中填充映射调用url的pin- if(!valueoftotal.equalsIgnoreCase("") && !valueoftotal.equalsIgnoreCase(null)) { if(Integer.parseInt(valueoftotal) > 0 &

我在谷歌地图上用pin图像显示地点,在
android
中调用

放大或缩小地图时,此url将一直刷新。
我使用此代码在
doInbackground
onpostExecution
AsyncTask
加载中填充映射调用url的pin-

if(!valueoftotal.equalsIgnoreCase("") && !valueoftotal.equalsIgnoreCase(null))
{
    if(Integer.parseInt(valueoftotal) > 0 && Integer.parseInt(valueoftotal) <= 100)
    {
        OverlayItem oi;
        if(myHandler.getParsedData()!=null)
        {
            arrayList = myHandler.getParsedData();      
        }

        linearbottom2.setClickable(true);
        mapOverlays.clear();
        //OverlayItem overlayItem,overlayItem1;
        overlay.removeAll();

        lineartabbar.setBackgroundResource(R.drawable.mapbar);

        if( arrayList.size()!=0 && arrayList.size()>1 )
        {
            for(int i = 0; i < arrayList.size(); i++)
            {
                String latvalue = arrayList.get(i).getLatitude().toString();
                String lonvalue = arrayList.get(i).getLongitude().toString();
                GeoPoint point = null;

                try
                {
                    point = new GeoPoint((int)(Double.parseDouble(latvalue)*1E6),(int)(Double.parseDouble(lonvalue)*1E6));
                }
                catch (NumberFormatException e) 
                {
                    // TODO: handle exception
                }

                if(point != null)
                {

                    if(arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
                    {  
                        oi = overlay.createItem(i);
                        System.out.println("overlayyyyyyyyyyyyy" + overlay + "\toiiiiiiiiii"+oi);
                        if(overlay!=null)
                        {
                            overlay.addItem(oi);
                        }
                     }
                     else if(!arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
                     {
                         oi = overlay.createItem(i);
                         if(overlay!=null)
                         {
                             System.out.println("2overlayyyyyyyyyyyyy" + overlay + "\toiiiiiiiiii" + oi);
                             overlay.addItem(oi);
                         }
                     }
                 }
             }
             mapOverlays.add(overlay);
             mapView.invalidate();
         }
         else if( arrayList.size()!=0 && arrayList.size()==1 )
         {
             for(int i = 0; i < arrayList.size(); i++)
             {
                 String latvalue = arrayList.get(i).getLatitude().toString();
                 String lonvalue = arrayList.get(i).getLongitude().toString();
                 GeoPoint point = null;
                 try
                 {
                     point = new GeoPoint((int)(Double.parseDouble(latvalue)*1E6),(int)(Double.parseDouble(lonvalue)*1E6));
                 }
                 catch (NumberFormatException e)
                 {
                     // TODO: handle exception
                 }

                 if(point != null)
                 {
                     if(arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
                     {
                         oi = overlay.createItem(i);
                         System.out.println("listing when 1 value is  "+arrayList.get(i).getUnitstotal());
                         overlay.addItem(oi);
                         mc.animateTo(point);
                     }
                     else if(!arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
                     {
                         oi = overlay.createItem(i);
                         System.out.println("listing when more value is  "+ arrayList.get(i).getUnitstotal());
                         overlay.addItem(oi);
                         mc.animateTo(point);
                         mc.setCenter(point);
                         mc.setZoom(18);
                     }
                 }
             }

             mapOverlays.add(overlay);
             mapView.invalidate();
             MapController mcontrller =mapView.getController();
if(!valueoftotal.equalsIgnoreCase(“”)&!valueoftotal.equalsIgnoreCase(null))
{
if(Integer.parseInt(valueoftotal)>0&&Integer.parseInt(valueoftotal)1)
{
对于(int i=0;i
但问题是,当我立即触摸地图时,它会移除所有针脚并开始加载新位置。我想平稳加载,首先获取所有位置,然后移除

请任何人尽快帮助我,对不起我的解释

public class HelloAndroidGpsActivity extends Activity implements OnClickListener, android.content.DialogInterface.OnClickListener 
{
     private EditText editTextShowLocation;
     private Button buttonGetLocation;
     private ProgressBar progress;

     private LocationManager locManager;
     private LocationListener locListener = new MyLocationListener();

     private boolean gps_enabled = false;
     private boolean network_enabled = false;

     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          editTextShowLocation = (EditText) findViewById(R.id.editTextShowLocation);
          progress = (ProgressBar) findViewById(R.id.progressBar1);
          progress.setVisibility(View.GONE);
          buttonGetLocation = (Button) findViewById(R.id.buttonGetLocation);
          buttonGetLocation.setOnClickListener(this);
          locManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
     }

     @Override
     public void onClick(View v) {
          progress.setVisibility(View.VISIBLE);
          // exceptions will be thrown if provider is not permitted.
          try {
               gps_enabled = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
          } catch (Exception ex) {

          }
          try {
               network_enabled = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
          } catch (Exception ex) {

          }

          // don't start listeners if no provider is enabled
          if (!gps_enabled && !network_enabled) {
                AlertDialog.Builder builder = new Builder(this);
                builder.setTitle("Attention!");
                builder.setMessage("Sorry, location is not determined. Please enable location providers");
                builder.setPositiveButton("OK", this);
                builder.setNeutralButton("Cancel", this);
                builder.create().show();
                progress.setVisibility(View.GONE);
          }

          if (gps_enabled) {
                locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
          }
          if (network_enabled) {
                locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener);
          }
      }

class MyLocationListener implements LocationListener {
    @Override
    public void onLocationChanged(Location location) {
        if (location != null) {
            // This needs to stop getting the location data and save the battery power.
            locManager.removeUpdates(locListener); 

            String londitude = "Londitude: " + location.getLongitude();
            String latitude = "Latitude: " + location.getLatitude();
            String altitiude = "Altitiude: " + location.getAltitude();
            String accuracy = "Accuracy: " + location.getAccuracy();
            String time = "Time: " + location.getTime();

            editTextShowLocation.setText(londitude + "\n" + latitude + "\n" + altitiude + "\n" + accuracy + "\n" + time);
            progress.setVisibility(View.GONE);
        } 
    }

    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }
}

@Override
public void onClick(DialogInterface dialog, int which) {
    if(which == DialogInterface.BUTTON_NEUTRAL){
        editTextShowLocation.setText("Sorry, location is not determined. To fix this please enable location providers");
    }else if (which == DialogInterface.BUTTON_POSITIVE) {
        startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
    }
}

}