MapView.zoomToBoundingBox() not zooming - osmdroid

I'm trying to zoom the map to a specific bounding box. I know I have to make the call AFTER the layout of the map is ready, so that is not the problem. The camera only gets centered on the bounding box, but it doesn't zoom as closely as possible, it just stays at whatever zoom level was set previously. What am I missing? How do I make it zoom as well?

The class MapController in the API allows to move and animate the map. Maybe you can look the zoomToSpanmethod.

Related

Osmdroid - Marker - increase selection area to get the InfoWindow

When selecting a Marker an InfoWindow pops up.
Sometimes the selection of a Marker is difficult. Especially when the map is rotating in the direction of navigation.
How can I increase the 'touch circle' so that selection is easier?
Update: I have to change the hitTest() for the Marker by subclassing.
I would like to check whether the 'hit' (or touch) was within a circle of X pixels around the point of the Marker. The icon will rotate while I navigate, so I guess I don't use the icon.
How can I do that?
public boolean hitTest(final MotionEvent event, final MapView mapView){
final Projection pj = mapView.getProjection();
pj.toPixels(mPosition, mPositionPixels);
// Does mPositionPixels contains the x, y of the Marker?
// Should I draw a Rect around this point, or could it be a circle?
// How can I check whether the event.getX(), event.getY() is a hit?
return hit;
}
Method proposed by spy is feasible.
You can also create your icon bitmap with an area of transparent pixels around. This is a very simple way to increase its touch area.
I believe #Mker would say, extend the Marker class and override the method hitTest. That is used for the Marker itself. I'm not sure if you can change this for the InfoWindow itself.

How do you make a clickable sprite in SFML?

I've been looking through the SFML documentation for making clickable sprites, but so far I haven't found anything.
Do you guys think you could help me out?
There is nothing like sf::ClickableSprite in SFML so far, and probably there will never be. (Current list of classes in SFML)
However, you can obtain this behavior with the sf::Sprite object and the events. The idea is simple - as soon as you get the sf::Mouse::isButtonPressed(sf::Mouse::Left) event, check if the mouse is in the sprite. If it is, perform the action. You can perform another action (maybe undo) when button is released.
There is sf::Sprite::getGlobalBounds() function which returns you the position and the dimensions of the sprite. There's also sf::Mouse::getPosition() function, which returns the current position of the mouse. You can use sprite.getGlobalBounds().contains(mousePos) to check whether the mouse is in the sprite.
If you're using views, you'll need to add the view's position to sf::Mouse::getPosition(window), since it gets the mouse position relative to window coordinates.
(thanks to Chaosed0 for additional notes.)

Handing a touch on a rotated CCLayer

After I rotate a CCLayer, my boundingBox grows, instead of rotating. Perhaps to be expected.
My issue is, I'm relying on a user touch on this layer. When the layer is rotated as in the figure on the bottom of the attached image, the clickable area increases because I'm calling:
if(CGRectContainsPoint(clickableLayer.boundingBox, touchLocation))
This causes an issue because this bounding box after rotation is covering up other things that are also clickable.
How do I only perform an action if the actual layer is touched? I want something to happen when just the green box is clicked, not the boundingBox of the layer.
Thoughts?
You can use CGMutablePathRef to detect transparent part:
Refer my answer in this thread.
Information about How to create CGPath:Here
For more information, Click Here
This thread got me to my answer: http://www.cocos2d-iphone.org/forum/topic/272336

Cocos2d sprite is drawn outside screen when transition

When I do page transition that shows the outside part of the stage (like CCTransitionFlipX), I can briefly see the sprites outside the screen while transition. It is really annoying. I thought I can manually check the position of the sprite in realtime and remove if it is off the screen. But that won't work if that sprite is partially outside. Is there something like UIKit's clipSubviews in cocos2d?
There's a ClippingNode class that might help.
Since the flip animation allows the user to see more than just the visible screen area, because the screen rotates, I think the behavior you observed may be expected.

what's the best way to display images in qt? also I would like to zoom in to particular areas as well

I've been using label to display images. I'd like to be able to click and create a bounding box then be able to drag the cursor to move around in the image. What would I need to do this? Thanks.
I'm not 100% sure I understand what you are trying to do, but I think the QGraphicsScene is what you are looking for. You can (among many other things):
Render images (QGraphicsPixmapItem, for example)
Change the zoom level when rendering the scene on a QGraphicsView.
Select things using a "rubber band"
Move items around with the mouse (see QGraphicsItem::ItemIsMovable)
etc.
You may need to get familiar with Qt's graphics view framework.