1

应用程序正在显示MapView,但无法放大到提供的坐标。我错过了什么...任何帮助将不胜感激

代码如下——

 public Screen()
{        
    // Set the displayed title of the screen       
    setTitle("Roamiing Checker");
    String currentNetwork = RadioInfo.getCurrentNetworkName();
    add(new RichTextField("Current Operator:"+currentNetwork, Field.FOCUSABLE));

    RichTextField roam_rtf = new RichTextField("",Field.FOCUSABLE);

    if(Check_NON_CAN_Operator())
    synchronized(Application.getEventLock())
    {
        roam_rtf.setText("Roaming");
    }
    else
    synchronized(Application.getEventLock())
    {
        roam_rtf.setText("Not in roaming");
    }

    add(roam_rtf);

    maps_rtf = new RichTextField("Waiting on current location.");

    loc = new LocationThread();
    loc.run();

    Timer timer = new Timer();
    timer.schedule(new LocationTimer(), 2*1000, 10*1000);

    add(maps_rtf);
    add(map_grid);

}

public class LocationTimer extends TimerTask
{
    public LocationTimer()
    {
    }

    public void run()
    {
        if(loc.getLatitude()==0 && loc.getLongitude()==0)
        {
            synchronized(App.getEventLock())
            {
                if(maps_rtf.getText().length() > 26)
                {
                    if(maps_rtf.getText().length() >  32)
                        maps_rtf.setText("Waiting on current location.");
                    else
                        maps_rtf.setText(maps_rtf.getText() + ".");
                }       
                else
                    maps_rtf.setText("Waiting on current location.");
            }
        }
        else
        {
            if(counter==0)
                synchronized(App.getEventLock())
                {
                    maps_rtf.setText("");
                    BBMaps(loc.getLatitude(),loc.getLongitude(),loc.getAltitude());
                    counter++;
                }
            else
                synchronized(App.getEventLock())
                {
                    maps_rtf.setText("");

                    map_coord = new Coordinates(loc.getLatitude(),loc.getLongitude(),loc.getAltitude());
                    mf.moveTo(map_coord);
                    map_grid.set(mf,2,1);

                    map_grid.set(new RichTextField("Latitude:- "+ loc.getLatitude()),3,1);
                    map_grid.set(new RichTextField("Longitude:- "+ loc.getLongitude()),4,1);
                    map_grid.set(new RichTextField("Altitude:- "+ loc.getAltitude()),5,1);

                    //BBMaps(loc.getLatitude(),loc.getLongitude(),loc.getAltitude());
                    counter++;
                }
        }
    }
}

public boolean Check_NON_CAN_Operator()
{
    boolean NON_CANOperatorCheck = true;

    final String CanadianOperators[] = {"Rogers Wireless" , "Telus" , "Bell"};

    String CurrentNetworkName = "";

    CurrentNetworkName = RadioInfo.getCurrentNetworkName();

    if( CurrentNetworkName.equalsIgnoreCase(CanadianOperators[0]) 
                || CurrentNetworkName.equalsIgnoreCase(CanadianOperators[1])
                ||CurrentNetworkName.equalsIgnoreCase(CanadianOperators[2]) )
        NON_CANOperatorCheck = false;               //if Current Operator is CANADIAN then **FALSE**
    else
        NON_CANOperatorCheck = true;                //if Current Operator is not CANADIAN then **TRUE** hence ROAMING

    return NON_CANOperatorCheck;
 }

public void BBMaps(double Lat,double Lng,float Alt)
{
    mf.setPreferredSize(mf_width, mf_height);           //480*100px

    map_coord = new Coordinates(Lat,Lng, Alt);
    mf.moveTo(map_coord);       //Maps pointing on the current location(if found unless Greenland)

    //Row 1
    map_grid.add(new RichTextField("Roaming State:- " + String.valueOf(Check_NON_CAN_Operator()),Field.FOCUSABLE));
    //Row 2
    map_grid.add(mf);           //Map Field added
    //Row 3
    map_grid.add(new RichTextField("Latitude:- " + Lat),Field.FOCUSABLE);
    //Row 4
    map_grid.add(new RichTextField("Longitude:- " + Lng),Field.FOCUSABLE);
    //Row 5
    map_grid.add(new RichTextField("Accuracy:- " + Alt),Field.FOCUSABLE);

} 

我正在严格地使用 OS 5.0..如果它是 6.0,使用新的 lbs.maps.* API 会更容易

4

0 回答 0