What's wrong with this simple piece of code?

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

What's wrong with this simple piece of code?

Postby Profete162 » Fri Mar 19, 2010 11:17 pm

Hi there, just a question that seems so simple:

I try to center my map in the center of 2 points and then adapt the zoom with a zoom spanning.

My problem came when i try to center the view in the middle: I use this soooo simple code:

Code: Select all
            double lat1 = gpGare.getLatitudeE6();
              double lat2 = gptest.getLatitudeE6();
              double lon1 = gpGare.getLongitudeE6();
              double lon2 = gptest.getLongitudeE6();
             
            GeoPoint gpMiddle= new GeoPoint((int)((lat1+lat2)/2),(int)((lon1+lon2)/2));
               
            monControler.setCenter(gpMiddle);
            monControler.setZoom(16);
            maMap.invalidate();


But the problem is that the zoom does not change! I become crazy! When i click on my button, the map center at the correct point but the zoom remain the same than before.


One other strange behaviour is then, when i want to change the zoom with the maps button, i go directly to zoom 16 that i asked before!!!! I sometimes make a step of 5 or 6 zoom level by clicking one time on the + or - button.


Please help me.


Profete162
Profete162
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Nov 27, 2009 6:07 pm

Top

Postby padde » Sat Mar 20, 2010 2:20 am

Try this instead..

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.     monControler.setZoom(16);
  3.  
  4.     monControler.animateTo(gpMiddle);
  5.  
  6.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby Profete162 » Wed Mar 24, 2010 8:07 am

I got my answer.It was so simple and stupid!

In fact, i was working without API Key, ( i was on debug mode and used the signed key) I thought that i would just have no maps and a white screen but it also affect the zoom...

As soon as i added the API key, all worked nice

Sorry for the waste of time.
Profete162
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Nov 27, 2009 6:07 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: Alexa [Bot] and 5 guests