How to show Latitude / Longitude in bing maps - c#-4.0

I have a silverlight application that contains Bing map.
I want when the user clicks on someplace on the map to show him the lat/long of the point where he clicked. is that possible ? and how?

This is very easy to do. I am assuming you know how to set up a mouse handler on the map. The parameter on the handler is of type MapMouseEventArgs, which contains the ViewportPoint Property, which is just an instance of the Point object documenting where on the viewport/map the click occured. You need to translate this viewport point to lat/long coordinates. To do this, use the ViewportPointToLocation Method on your Map object, which as the name implies translates your viewport point to a Location(lag/long) object. After you get the lag/long, just show it to the user however you'd like.

Related

Making and Object uniteractable

So I have a part of my game where the character is selecting an area of the map. And it opening up a panel. I have made it so that happens but an=m now stuck on the other part of it. I want only certain area of the map to be intractable, so that I can bar the player from selecting areas of the map that they aren't ready for. I have no idea how to make game objects in the game uninteractable. I have looked on Stack overflow, Youtube an d the Unity API to no success. Can someone help me with that.
How to make things un-interactable will vary depending on your situation. I'll be presuming that you're map is broken up into a grid of sorts.
The basic setup would involve a bool, probably called 'CanAccessZone'.
Then you'll need a class, to store any access info and popup logic, by popup logic I mean make the element either non-interactable or show a popup, with the shown popup being dependant on 'CanAccessZone'. This class can then be set up by your Map class when the level is loaded, or you could let the popup class grab the necessary values from the Map class.
If you're using Unity's UI buttons for the map pieces, then you could set interactable to false, until you want to let the player access the zone. If you want to display a popup informing the player that they can't access the zone, then your button will be interactable, but the click will delegate to your popup logic method.
It's a similiar principle if you're using gameobjects as buttons. You'd be using any of the OnMouse events to handle click events. https://docs.unity3d.com/ScriptReference/MonoBehaviour.html
Hopefully this'll lead you in the right direction.

How do I change the image rendered for just one eye?

I'm new to the google cardboard sdk. I need to draw a slightly different image for the left eye as compared to the right(I know distortion correction is taken care of). I saw the "Eye" class spec (an instance of which is passed to OnDrawEye()) from the docs.It does not seem to contain info of which eye is being referred to. How do I tell if the image is being rendered for the right or left eye and code accordingly?
In the class where you implements the CardboardView.StereoRenderer you have to define the function onDrawEye(), int this function you receive a parameter of type Eye, from that parameter you can know what eye is rendering at the moment with the function getType(). You can check the eye with the constants defined in Eye.Type

How to rotate and place points on VTK object

I have seen how I can place points on a VTK object using seed widget from : http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/vtkSeedWidget
I have also seen how I can rotate an object from : http://www.cmake.org/Wiki/VTK/Examples/Cxx/Qt/SideBySideRenderWindows
I am wondering how I can combine this so I can rotate the object when I drag, and place points when I click
Usually to do something like this you will have to subclass an interactor style (like this: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEvents). Then you can store an instance of something like the seed widget in that class, and pass along events to it that you don't want to handle, and handle the ones that you do want to handle (or let the defaults of the style handle them).

Rotating MKMapKit

I am attempting to rotate an MKMapView using MapKit.
I can display a map and rotate it, however not very efficiently. I create an MKMapView larger than the view and rotate it using CGAffineTransformMakeRotation, so the the grey areas behind the view are not visible. Although I have clip subviews checked in Interface Builder, I still have the feeling this is not the correct implementation.
This method does allow me to rotate any annotations displayed as MKPinAnnotationView conforms to the CGAffineTransformMakeRotation function, but I come into problems when trying to add an overlay to the map.
I can place an overlay on using the boundingMapRect property in the class declaration but the image remains unrotated on the display. Is there a way to achieve this? Or alternatively should I be rotating the MKMapView and annotations in a different method?
Thanks in advance for any advice or information.
Are you rotating the map so that it is facing the same way the user is? (i.e. not just North = Up). If so you don't need to do any transformation stuff at all, just set the MKUserTrackingMode to MKUserTrackingModeFollowWithHeading

How to know the number of pixels that a String is occupying?

I have an item ( TextField, or TextArea, ...). It has a content value , say "hello world". How to know the number of pixels that this "hello world" String value is occupying on the screen ?
You can get the preferred width/height to get a rough estimation (you would also need to add the margin's to get accurate sizing). However the layout manager views these as guidelines not as final sizes and can decide on placing a component anywhere.
During runtime e.g. paint etc. the getX/Y/Width/Height argument provide accurate component size and position. However, these are only valid for the current paint operation since a device may be rotated or might require layout reflow.
You need to be more specific on what you are trying to accomplish.

Resources