Hi , How can i set a default zoom to my XampMap when its displayed ,
thanks
Hi bouhmid86,
A sample approach to achieve this could be the following.
XAML: <igMap:XamMap x:Name="map1" Loaded="map1_Loaded"> <igMap:XamMap.Layers> <igMap:MapLayer x:Name="statesLayer"> <igMap:MapLayer.Reader> <igMap:ShapeFileReader Uri="Shapefiles/usa/usa_st" DataMapping="Name=STATE_NAME; Value=POP1997; Caption=STATE_NAME"/> </igMap:MapLayer.Reader> </igMap:MapLayer> </igMap:XamMap.Layers> </igMap:XamMap>
CB: private void map1_Loaded(object sender, RoutedEventArgs e) { ZoomMapToRegion(3); }
public void ZoomMapToRegion(double zoom) { DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1.0) };
timer.Tick += (o, e) => { map1.WindowZoom = zoom; ((DispatcherTimer)o).Stop(); };
timer.Start(); }
Hope that helps,Milana Zhileva
Thanks, it works but iwant this zoom centred in france , how can i do this , thanks a lot
Are you using a shapefile or some multiscale imagery as Bing Maps, Open Street Map etc.?
Thanks,Milana Zhileva
Hi,
To zoom initially into France, you could try something like this.
XAML: <igMap:XamMap x:Name="mapEurope"> <igMap:XamMap.Layers> <igMap:MapLayer x:Name="europeLayer" Imported="europeLayer_Imported"> <igMap:MapLayer.Reader> <igMap:ShapeFileReader Uri="Shapefiles/europe/europe" DataMapping="Name=CODE; Caption=CNTRY_NAME; Value=POP_CNTRY"/> </igMap:MapLayer.Reader> </igMap:MapLayer> </igMap:XamMap.Layers> </igMap:XamMap>CB: private void europeLayer_Imported(object sender, MapLayerImportEventArgs e) { if (e.Action == MapLayerImportAction.End) { ZoomMapToRegion("France"); } }
public void ZoomMapToRegion(string region) { DispatcherTimer timer = new DispatcherTimer();
timer.Tick += (o, e) => { foreach (MapElement el in mapEurope.Layers[0].Elements) { if (el.Caption == region) { this.mapEurope.WindowRect = el.WorldRect; } }
((DispatcherTimer)o).Stop(); };
Best Regards,Milana Zhileva
Hi Milina , i m using ShapeFile in my XamMap , the zoom works greate but i want to set it to a specific palce "france " for exemple