I've recently downloaded and installed Windows 8 OS along with Visual Studio 2012 and I'm trying to port an old project I built on Windows Phone 7 to WP8.
It has a map that originally had a MapPolygon in it so that whenever you zoom in/out the polygon was always proportional based on the zoom level.
MapPolygon is still a valid class using the new Map control (not Bing Maps Control) but I have no idea how to add it to a map to get the same features/properties.
I think it has to do with the MapElements which should allow to add a shape to the map in the following fashion.
MapPolygon shape = new MapPolygon();
shape.Path.Add(new GeoCoordinate(55.859185825719055, 2.2946083545684877));
shape.Path.Add(new GeoCoordinate(55.858185825719055, 2.2956083545684877));
shape.Path.Add(new GeoCoordinate(55.857185825719055, 2.2946083545684877));
shape.Path.Add(new GeoCoordinate(55.858185825719055, 2.2936083545684877));
shape.StrokeThickness = 3;
shape.StrokeColor = Colors.Blue;
shape.FillColor = Colors.Black;
map1.MapElements.Add(shape);
Nothing shows on the map.
I've also tried to add a Grid to a MapOverlay to a MapLayer to a Map but I have no idea how/where to add the MapPolygon in this way.
Ridiculous mistake.
My map wasn't centered at the same place as the GeoCoordinates were added to the shapes path.
Related
I am having trouble finding a solution for my problem. I am looking to set the padding for the Xamarin Forms Map (Mapkit/MKMapView) on iOS (Custom Renderer).
For Android it can be set in the custom renderer with NativeMap.SetPadding(10,200,10,10) but I cannot find a way to do it in iOS.
The problem I am trying to solve is that the compass on the map appears on the top right corner of the map (iOS) and since I do have my own controls on the top of the map, the compass is not accessible.
On android setting the padding pushes the compass down below my controls and solves the issue.
I’d appreciate any suggestion on how to solve it for iOS
MapKit.MKMapView
You can create your own MKCompassButton and alter its X/Y position (via its Frame) on the map.
var compass = MKCompassButton.FromMapView(mkMapViewInstance);
compass.CompassVisibility = MKFeatureVisibility.Visible;
compass.Frame = new CGRect( new CGPoint(25,25), compass.Frame.Size);
re: https://developer.apple.com/documentation/mapkit/mkcompassbutton?language=objc
Google.Maps.MapView (iOS)
You can add padding around the edges of the map using the GMSMapView.padding property. The map will continue to fill the entire container, but text and control positioning, map gestures, and camera movements will behave as if it has been placed in a smaller space. This results in the following changes:
myGMSMapViewInstace.Padding = new UIEdgeInsets(100.0f, 100.0f, 100.0f, 100.0f);
I have an .mbtiles file and I am using it for offline map (iOS MapBox SDK). But my .mbtiles doesn't have enough data (just simple green rectangle). I want to draw some lines(roads) between points (I download it from my rest API). I found the solution to use RMShape, but I want to use already drawn map. I create my .mbtiles from osm and TileMill. Help me out please.
WhirlyGlobe-Maply SDK can help you achieve this.
It has a mapview and a globe view which you implement on your viewcontroller.
Then you create a layer using your mbtile file as shown below:
let tileSource = MaplyMBTileSource(mbTiles: "your-mbtile-filename")
You add this layer on the globe or map to display the tiles.
And using SDK's function like addShapes(), you can add, circles, vectors, labels, text and icons on the map/globe.
I tried adding lat and long lines programatically. Also tried adding some labels and spheres.
This is how it looks ->
WhirlyGlobe-Maply using mbtile and drawing on top of it
I'd like to draw a grid into my map, that represents the size of a tile at a certain zoom level. So for example I'd like to have a grid on my mapview that shows the outline of a zoom level 10 tile. So the outline of where this tile would be. No matter if the mapview itself is at zoom level 5 or 15, it should display the outline of where that tile would be placed.
The problem I have is how to calculate the proper rect that represents each visible "tile".
Any help is sooo much appreciated!!!
Or maybe the answer to following question would help:
How can I convert a MKMapRect to a MKTileOverlayPath?
I find that MapKit is way too limited when you want to start doing more and more with maps.
I would reccomend using Google Maps SDK for iOS: https://developers.google.com/maps/documentation/ios/start
and then using GMSTileLayer for the tiles:
https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_tile_layer
In the long run, replacing MapKit with Google maps gives you far more features and options and has better geolocation and reverse geolocation than Apple
You can also look at Mapbox. Between using TileMill to create a grid layer by setting the Map background to a pattern image, you could then only export zoom level 10 and either host it on Mapbox or export it to MBTiles format (SQLite-based). Then one of the Mapbox mobile toolkits could serve the tiles out as an overlay on your map.
I've been working on a project that helps create a virtual reality experience on the laptop and/or desktop. I am using XNA 4.0 on Visual Studio 2010. The current scenario looks like this. I have interfaced the movements of a persons head through kinect. So if the person moves his head right relative to the laptop, the scene seen in the image is rotated towards the left giving the effect of a virtual tour or like looking through the window experience.
To enhance the visual appeal, I want to add a darkness at the back plane. Like the box looks as if it was a tunnel.
The box was made using trianglestrips. The BasicEffect used for the planes of the box is called effect.
effect.VertexColorEnabled = true;
effect.EnableDefaultLighting();
effect.FogEnabled = true;
effect.FogStart = 35.0f;
effect.FogEnd = 100.0f;
effect.FogColor = new Vector3(0.0f, 0.0f, 0.0f);
effect.World = world;
effect.View = cam.view;
effect.Projection = cam.projection;
On compiling the error is regarding some normals.
I have no clue what they mean by that. I have dug the internet hard enough. (I was first under the impression that ill put a black omnilight in the backside of the box).
The error is attached below:
'verts' is the VertexPositionColor [][] that is used to build the box.
How do I solve this error ? Is the method/approach correct ?
Any help shall be welcome.
Thanks.
Your Vertex has Position and Color channels, but is has no normals... so you have to provide vertex has it.
You can use VertexPostionNormalTexture if you don't need the color, or build a custom struct that provides the normal...
Here your are a custom implementation: VertexPositionNormalColor
You need to add a normal (vector3) to your vertex type.
Also if you want Distance fog you will have to write your own shader as BasicEffect only implements depth fog (which while not looking as good is faster)
I'm trying to draw a circle with specific radius in km (for example 2km) on a MapView at specific lat/lng. I've found some samples:
Creating Custom Overlay on the map
Draw A Circle On Android MapView
Draw circle of certain radius on map view in android
I think first and second of above are useful but these are in Java and I need code for Mono for Android (Monodevelop).
I can't find Projection class in monodroid.
And can't use com.google.android.maps.Projection.
Can somebody help me how to use these codes in monodroid?
com.google.android.maps.Projection is an interface, so it is made available in Mono for Android as Android.GoogleMaps.IProjection to keep with normal C# conventions.
Similarly, where you'd use mapView.getProjection() in Java, in C# it is made available via the Projection property on MapView.
Xamarin has some tutorials on their site that go over how to use these to create custom overlays, so I'd suggest checking them out.