How to put a picture exactly on the road? - c#

I created Custom Pin in Xamarin.Forms.Maps and add my icon. How I can put my icon on the road and and move this icon along.My problem is not with getting accurate data, but with displaying the image itself exactly on the road. For example, if the road is horizontal, then the icon (car) should stand horizontally on the road

You could use Map Tracking. It would show the driver route and car position on the map. The car should move according to its current position in the route.
Install the Xamarin.Forms.GoogleMaps.
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
You could download the source file from the GitHub for reference.
https://github.com/WendyZang/MapTrackingSample

Related

SharpMap - display an overlay image synchronized with the map (georeferencing functionality)

Using SharpMap (Windows Forms) how can I display an overlay image over the map tile background so that the image scales and moves accordingly with the map zoom and pan? I want to implement a georeferencing like functionality.
I tried using SharpMap.Layers.GdiImageLayer but I didn't find a way to position it to a custom position (real world coordinate) - it is getting placed by default at origin [0,0] (the background tile coordinates). Is there a way to define a relation (transformation) to place it in a particular position?
I managed to get closer to a solution using VectorLayer with RasterPointSymbolizer but the symbol (image loaded for symbol) would need to be transformed on map scaling/zoom (so that corners remain in the same real world coordinates) - the math calculation behind looks a little complicated for a solution that seems more like a workaround than a natural one. As a note - I don't need precise calculation using projection/real geoid as I am doing this only at building level.
Using GDAL - GeoTIFF might be a choice here by generating a GeoTIFF based on the original image and making the georeferencing metadata dynamic based on UI controls? The original image is in raster format (JPG) with no geographic metadata.
Is there a better solution?
If VectorLayer - RasterPointSymbolizer is the best choice, do you have an example for symbol(image) synchronization with the map view?
As far as i can tell the GdiImageLayer calculates the position based on a world-file (GdiImageLayer.SetEnvelope()). Here is the link to the method. This meta file has to have the same name in the same location but the filetype must be of type *.wld. There you set the position (top left corner) and the skew in x and y axis. So rotation will be perserved. I never tried this but i would suggest correct zooming would work
(The wiki article offers also some good understanding for world files)
There might be another way if no world file is present and the information rests in the header. There is a GDalSample loading a GeoTiff Image onto an existing map. The example can be found in the WinFormSamples and the Different kind of layers supported by [MapBox] Example. The map is showing the overlay only while magnifying and not fully function but maybe a good hint

Change point size with sketch editor

I'm using the sketch editor to let the user draw and edit polygons on map
I want to let the user the option to move/rotate/resize etc.
when I create polyline/polygone I can do it with no problem as I send the geometry to the sketch editor
but when I want to create a point, I cannot resize and rotate it, only move the point along the map
(because sometimes my point are represented with a symbol, for example, truck)
is such option even exist?
P.S
I know I can go directly to the geometry / SimpleMarkSymbol and change it properties, but that's not an optimal solution for me

How to scale objects with screen size in Unity

For canvas item no problem, buttons or any other UI elements can be scaled with screensize. On the other hand, I can not do this for objects. I need a box in my design and in every screensize it should fit all screen.
I need this design.
But when I change screensize design does not remain same.
other image:
For button or canvas elements there is no problem I can do it by "scale with screen size" but when it comes to objects I can not do like this. How can I do?
It seems like a vignette would be useful rather than scaling a gameobject.
Quick explanation:
With Unity's post-processing properly added and a volume created, add the effect/override of vignette and change vignette's mode to mask. And add an image as a mask.
If not experienced with post-processing:
For unity 3d HDRP or URP(may work with unity 2d but probably not):
Add a global volume through the hierarchy by first navigating to the plus sign drop-down then to volume then click on global volume. If unavailable, add an empty object with a volume component. Create a profile then add the override of the vignette. Under vignette change the mode to mask and select an image you want the mask to be.
That should be all for unity HDRP or URP.
Without HDRP or URP:
Add the postprocessing package if not installed via the package manager.
Create an empty object and add post-processing volume. Checkmark is-global. Create a new post-processing profile. Add effect vignette. Checkmark 'Mode' and switch it to masked.
Checkmark and change 'Mask' to the image you want.
This should allow the image to pop up over the camera.
Extra note: Make Sure The Image Has A Transparent Background On The Vignette Mask Where You Want The Player To See Through
Please search for how to use post-processing package if any issues occur.

What is the correct method for showing a full screen photo within a mobile app using Unity?

I am creating a mobile app using Unity. I would like to place a photo which fills the screen and then place some 3D objects on top of this photo. The photo is created during runtime and is saved to the persistance data folder.
What is the best method to achieve this? The options I see are Raw Image/Image/Sprite. However, I have been unable to achieve the above mentioned goal using either of these component types.
What about making a panel on a canvas, setting the image as background and the canvas to fit screen size?
Then place the objects on front of it, manually or as children of said canvas but higher in the hierarchy.
I don't really understand what you intend to do, just trying to help.
editing my original answer: you need to use RawImage to be able to easily load images that are not marked as Sprite in the editor
You load images from file like this :
Texture2D texture = new Texture2D(1,1); // the following needs a non null starting poin
var path=System.IO.Path.Combine(Application.streamingAssetsPath,"your_file.jpg");
byte[] bytes=System.IO.File.ReadAllBytes(path);
texture.LoadImage(bytes);
rawImage.texture=texture;
As far as keeping it filling the screen the AspectRatioFiter component is likely to do the job
To get 3d objects rendering in front, set your canvas to 'Screen Space - Camera' and point it to your camera. This will behave similar to word space in regards to rendernig order (will get 3d sroted) but canvas size will match camera viewport, so AspectRatioFitter will be able to do its job

Shape from Pushpins, actions on them

I am very curious, I have for example a app to localize our property, our first, second house, favorite park and we can add pushpins to corners of this property in a way to form a shape(triangle, square, polygon etc), not a line or point.
How to create this shape, there is a method to calculate the surface area? Change a background for example to color yellow between these pushpins ?
When we created a shape we can chose from the listbox or map to delete this shape or go to there using GPS, i wrote something like that in Simulate my current position
I think its a interesting app but i need your help ;)
Try getting the geocoordinates of each pushpin and using maths? I guess you could assume the flatness of the Earth over a small area (like a house) but over larger you'll need to account for curvature.
As for colouring the shapes in, I don't think there's a way to do this using the Map control.

Categories

Resources