I'm developing an App in which the map will be shown to user and I need to add around 10-12 images to the map at different GeoPoints each having 1KB of size.
I'm adding those images dynamically as per below:
Image img = new Image();
img.Height = 35;
img.Width = 35;
img.Source = new BitmapImage(new Uri("ms-appx:///Assets/myImage.png"));
img.RenderTransform = new CompositeTransform() { Rotation = item.bearing };
MapControl.SetNormalizedAnchorPoint(img, new Point(0.5, 0.5));
MapControl.SetLocation(img, new Geopoint(new BasicGeoposition() { Latitude = item.latitude, Longitude = item.longitude }));
myMap.Children.Add(img);
My Problem is
After I add those 12 images, my Map control becomes soo Laggy that while moving the map from one location to other, it hangs a lot.
So, is there any efficient way to add images to Map in windows phone 8.1 App.
Edit:
I've tried to add MapIcons
to the Map, but in that case MapIcons were disappeared at specific zoom level, but i want to keep those MapIcons visible at any zoom level.
So is there any way I can make MapIcons
visible for every zoom level?
You could use the MapIcon class instead, this would be handled better as the map is a native C++ control, so it has to do a lot of work to position XAML elements on the map. The MapIcon class is a native class so it renders much better. You will need to convert your image into a RandomAccessStream and then pass it into the MapIcon image property. This may help: https://blogs.msdn.microsoft.com/going_metro/2012/05/14/working-with-streams-creating-randomaccessstreamreference-from-image-downloaded-from-web/
You can then add the MapIcon's to the maps MapElements property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With