PDA

View Full Version : Mercator for google static maps



daarsh
29th September 2010, 06:59
Hi,
I am new to QT and m developint an application for mobile.
I want to display google map and also put some buttons at specific places on the map.
Earlier I thought of using QWebview and google maps javascript API.
But then in that case I was not able to get the current location being displayed on map.
So I am trying to use static map api.
I am displaying the map image in a graphics scene so that I am able to drag the image.
Now I want to place some buttons @specific position on the map.For that i need to convert the lat lon in the map image to pixels.I have heard about mercator algo for that,but i didnt fing any cpp implementation for it :(
I am not sure how to do this.
Also How can i plave a button over the graphicsview wigdet,coz i am using layouts.
any help will be appriciated.
Thanx in advance

SixDegrees
29th September 2010, 07:33
First, you need to know what projection the map is displayed in; you can't just blindly reach for the Mercator projection, because it is only one of literally hundreds of map projections available. For relatively close-up views, orthographic projections are often used, or just a simple Platte-Carre projection which uses a direct mapping between screen coordinates and latitude/longitude. But you have to determine which is being used; whatever the source of your map image is should provide this information.

Once you know that, there are many sources for converting between various projection frames. Flattening the Earth: 2000 Years of Map Projections (http://www.amazon.com/Flattening-Earth-Thousand-Years-Projections/dp/0226767477/ref=sr_1_1?s=gateway&ie=UTF8&qid=1285741925&sr=8-1) is probably the best reference on the topic that's readily available.

Urthas
29th September 2010, 07:36
A layout can be given widgets and other layouts, which it arranges in different ways depending on its type -- see Layout Management (http://doc.qt.nokia.com/4.6/layout.html) for more information.

Once you have your layout structure defined, use QGraphicsView::setLayout(QLayout *).

daarsh
29th September 2010, 07:49
Thanx a lot guys for the Quick replies.
@ Urthas
I have some info abt layouts,
but haw can we put the buttons in the layout according to our choice??
In VBox/HBox Form and grid layouts,we are not able to give the exact locations to our widgets right??

Urthas
29th September 2010, 08:01
but haw can we put the buttons in the layout according to our choice?? In VBox/HBox Form and grid layouts,we are not able to give the exact locations to our widgets right??

Not as such. But you can frequently get widgets laid out acceptably by nesting layouts and using spacing elements. If you are wanting to put widgets (like buttons) at specific, context-dependent locations you will probably have to embed them in the QGraphicsScene instead of the QGraphicsView by using QGraphicsProxyWidget (http://doc.qt.nokia.com/4.6/qgraphicsproxywidget.html).

daarsh
29th September 2010, 08:53
@urthas..
thnx for the pointer buddy...vl try this proxy wodget!!

daarsh
29th September 2010, 11:43
@ SixDegrees: thnx for the reply.
Was trying to search the projecction which google uses for static maps,but no success...
do u know...or any guesses??