Mobile GMaps Home Page
 FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups   RegisterRegister  
 ProfileProfile    Log in to check your private messagesLog in to check your private messages    Log inLog in 

Drawing markers

 
Post new topic   Reply to topic   printer-friendly view    MGMaps Forum Index -> Developer Forum
View previous topic :: View next topic  
Author Message
kolaf
Developer


Joined: 22 Jul 2006
Posts: 23

Phone Type: Unknown

PostPosted: Sun Aug 27, 2006 9:06 pm    Post subject: Drawing markers Reply with quote

I'm now attempting to draw received stations on the map. I use the following function call:
Code:

Props.markers.addMarker(GMarker.MRK_OTHER, GMarker.ICON_BLUE, f.getPos(), f.getName());

where f.getPos() returns a GPoint with the station's position and getName is a string. I have added a function to Markers which adds a marker based on GPoint instead of GMapPos.

Now, in the paint function of GMarker where the markers are drawn on screen if they are within the bounds reports are correct latitude and longitude for its position, the on screen coordinates are a way off, placing the point somewhere in the Indian Ocean instead of in Norway.

I paste in a sample debug output from the paint function:
Code:

Testing LA3XMA-10
cachePos.x: 2769, cachePos.y: 1928
(pos.x) lat: 63401833, (pos.y) lon: 10423166
Left: 680, Top: 857
iw: 10, ih: 17

The output is generated by the following debug code in paint:
Code:

 public void paint(Graphics g, GMapPos centerPos) {
    // get width and height
    // get screen coords, given the center position
    if (cachePos == null || cachePos.zoom != centerPos.zoom)
      cachePos = GPoint.fromLonLat(pos, centerPos.zoom, centerPos.mode);
    GPoint screenPoint = centerPos.toScreen(cachePos);
    int left = screenPoint.x-(iw>>1);
    int top = screenPoint.y-ih;
    Logger.debug("Testing "+text);
    Logger.debug("cachePos.x: "+cachePos.x +", cachePos.y: "+ cachePos.y);
    Logger.debug("lat: "+pos.x+", lon: "+ pos.y);
    Logger.debug("Left: "+left +", Top: "+ top);
    Logger.debug("iw: "+iw +", ih: "+ ih);


The map is centred over Norway is in town to show most of Norway, Sweden, and some of England. In other words, the point should be on screen. However, as you can see the left and top parameters for the point far away from its position.

I do not really assume you have any good answers, but perhaps you have some suggestions as to where I should look?
Back to top
View user's profile Send private message Visit poster's website
kolaf
Developer


Joined: 22 Jul 2006
Posts: 23

Phone Type: Unknown

PostPosted: Sun Aug 27, 2006 9:17 pm    Post subject: Reply with quote

Heh, never mind.

I'm used to a "lat, lon" format, but your "x,y" was "lon, lat". Should have spotted it earlier... :-/
Back to top
View user's profile Send private message Visit poster's website
Cristian Streng
Founder


Joined: 28 Oct 2005
Posts: 4585

Phone Type: (many)

PostPosted: Mon Aug 28, 2006 6:43 am    Post subject: Reply with quote

Right... well the code for the markers will undergo some big changes in a future versions, that's one part that's definitely not well designed.

Cristian
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MGMaps Forum Index -> Developer Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
MGMaps topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group