public static void AddHeatMapLayer(Layer layer, View view) { Map map = view.Map; string originalTitle = string.Empty; originalTitle = layer.GetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty) as string; FeatureLayer featureLayer = layer as FeatureLayer; if (featureLayer != null && !string.IsNullOrEmpty(featureLayer.Url)) { HeatMapFeatureLayer heatMapFeatureLayer = new HeatMapFeatureLayer(); heatMapFeatureLayer.DisableClientCaching = featureLayer.DisableClientCaching; heatMapFeatureLayer.Geometry = featureLayer.Geometry; heatMapFeatureLayer.ProxyUrl = featureLayer.ProxyUrl; heatMapFeatureLayer.Text = featureLayer.Text; heatMapFeatureLayer.Token = featureLayer.Token; heatMapFeatureLayer.Url = featureLayer.Url; heatMapFeatureLayer.Where = featureLayer.Where; heatMapFeatureLayer.MapSpatialReference = map.SpatialReference; heatMapFeatureLayer.ID = "EsriHeatMapLayer__" + Guid.NewGuid().ToString("N"); foreach (Graphic item in featureLayer.Graphics) { ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = item.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint; if (mapPoint != null) heatMapFeatureLayer.HeatMapPoints.Add(mapPoint); } view.AddLayerToMap(heatMapFeatureLayer, true, string.IsNullOrEmpty(originalTitle) ? Resources.Strings.HeatMap : string.Format(Resources.Strings.HeatMapTitle, originalTitle)); } else { GraphicsLayer graphicsLayer = layer as GraphicsLayer; if(graphicsLayer != null) { ESRI.ArcGIS.Client.Toolkit.DataSources.HeatMapLayer heatMapLayer = new Client.Toolkit.DataSources.HeatMapLayer(); foreach (Graphic item in graphicsLayer.Graphics) { ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = item.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint; if (mapPoint != null) heatMapLayer.HeatMapPoints.Add(mapPoint); } view.AddLayerToMap(heatMapLayer, true, string.IsNullOrEmpty(originalTitle) ? Resources.Strings.HeatMap : string.Format(Resources.Strings.HeatMapTitle, originalTitle)); } } }
public void InitializeMapView(View View) { //if (ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView.Current == null) //{ ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView mapView = new ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView(null); ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.AppControls.PrintTarget = View.Map; mapView.MapReadyForInsertion += (o, args) => { View.RemoveMap(); View.AddMap(args.Map); bool same = (View.Map == ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView.Current.Map); }; mapView.MapReadyForRemoval += (o, args) => { View.RemoveMap(); }; View.MapRecreated += (o, args) => { ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView.Current.Map = args.NewMap; }; MapDocument oldDoc = (MapView.Current == null) ? null : MapView.Current.Document; ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView.Current = mapView; mapView.Initialized += mapView_Initialized; ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapDocument doc = ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapSerialization.MapDocumentHelper.UpdateMapDocument(View.Map, oldDoc); //MapViewInitialized += callback; ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView.Current.Initialize(doc); //} //else //{ // ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapSerialization.MapDocumentHelper.UpdateMapDocument(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView.Current.Map, ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.MapView.Current.Document); // if (MapViewReady) // callback(null, null); // else // MapViewInitialized += callback; //} }