Note that there are some explanatory texts on larger screens.

plurals
  1. POHow are we supposed to draw polylines on Here maps with Windows Phone 8?
    text
    copied!<p>I'm trying to draw a polyline on Here Maps, and can't find any tutorial or decent documentation on that subject.</p> <p>Here's what I've been doing up to now.</p> <p>I create my map directly in the view:</p> <pre><code>&lt;maps:Map x:Name="map2" Grid.Row="1" Margin="0,0,0,0" Loaded="HereMap_Loaded"/&gt; </code></pre> <p>When the map is available, it calls this code:</p> <pre><code>private void HereMap_Loaded(object sender, RoutedEventArgs e) { initData(); map2.Center = new GeoCoordinate(0, 0); map2.ZoomLevel = 13; map2.LandmarksEnabled = true; //Shows 3D buildings when available. draw(); } </code></pre> <p>The call to draw does this:</p> <pre><code>public void draw() { Microsoft.Phone.Maps.Controls.MapPolyline polyline = this.createPolylineFromArray(arrayOfGeoCoordinates); polyline.StrokeThickness = 12; polyline.StrokeColor = Color.FromArgb(255, 189, 179, 217); MapOverlay overlay = new MapOverlay { Content = polyline }; Microsoft.Phone.Maps.Controls.MapLayer layer = new Microsoft.Phone.Maps.Controls.MapLayer(); layer.Add(overlay); map2.Layers.Add(layer); } </code></pre> <p>And I create my polyline from a list of GeoCoordinates:</p> <pre><code>public Microsoft.Phone.Maps.Controls.MapPolyline createPolylineFromArray(List&lt;GeoCoordinate&gt; pArray) { if (pArray.Capacity &gt; 1) { GeoCoordinateCollection path = new GeoCoordinateCollection(); foreach (GeoCoordinate coordinate in pArray) { path.Add(coordinate); } Microsoft.Phone.Maps.Controls.MapPolyline polyline = new Microsoft.Phone.Maps.Controls.MapPolyline { Path = path }; return polyline; } return null; } </code></pre> <p>Now, I tried to create a circle overlay instead of a polyline before, and it worked. I've done it this way:</p> <pre><code>Content = new Ellipse { Fill = new SolidColorBrush(Colors.Red), Width = 40, Height = 40 } </code></pre> <p>When I replaced the circle overlay with the polyline as shown above, it displays the following picture:</p> <p><img src="https://i.stack.imgur.com/feWQI.png" alt="Polyline error"></p> <p>You perfectly see the map, and the overlay appears as a texte line at the upper edge of the screen, displaying the overlay class package name.</p> <p>What am I missing? I'm expecting it to display a polyline that will follow the map movements.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload