Hi,
I had an issue with a simple application showing a heat map. At first I define inside the view / map / CustomOverlays my layeroverlay and my layer heat map. But when running the application I was always getting a message like object not defined visible only for few milliseconds and then the application was just running OK. Then I try to define the layer overlay inside the view and the heat layer inside the controller. Doing so removed the initial error..... I was unable to trap the error when using the view to define both overlay and layer. maybe there is a bug ....
The heat layer was populated using the ajax way... I mean that just having the layeroverlay and heat layer was enough to see rhe error message and of course the error message was visible when I disabled the call to populate the heat layer using Ajax.
Do you think that if we have to use a view we have not only to define the layeroverlay and heat layer but also we have to populate / load the heat layer with data points????
thanks.
Map2.ajaxCallAction(_controllerId, 'getHeat', {}, function (result) {
var _r = result.get_responseData();
var format = new OpenLayers.Format.WKT();
var feature = format.read(_r).geometry;
Map2.zoomToExtent(feature.getBounds());
Map2.redrawLayer('Heat');
});
@{
Html.ThinkGeo().Map("Map2", System.Web.UI.WebControls.Unit.Percentage(100), System.Web.UI.WebControls.Unit.Percentage(100))
.MapBackground(new BackgroundLayer(new GeoSolidBrush(GeoColor.StandardColors.White)))
.CurrentExtent(-14148507.181077, 6271924.7354557, -5114687.7715466, 3097880.0780531)
.MapUnit(GeographyUnit.Meter)
.MapTools(mapTools =>
{
mapTools.MouseCoordinateMapTool().Enabled(false);
mapTools.PanZoomBarMapTool().Enabled(false);
mapTools.LoadingImageMapTool().Enabled(false);
mapTools.TouchMapTool().Enabled(true);
mapTools.MouseMapTool().Enabled(true);
mapTools.KeyboardMapTool().Enabled(false);
mapTools.ScaleLineMapTool().Enabled(false);
mapTools.PanZoomMapTool().IsGlobeButtonEnabled(false).Enabled(false);
})
.CustomOverlays(overlays =>
{
overlays.WmsOverlay("WMS Overlay")
.Parameters(paras =>
{
paras.Add("LAYERS", "WorldMapKitRL_SPHMCT");
paras.Add("STYLES", "DEFAULT");
paras.Add("SRS", "EPSG:4326");
})
.ServerUris(uris =>
{
for (int x = 0; x <= 4; x++)
{
uris.Add(new Uri("GEOWMS.USAC.MMM.COM:80/WmsHandler.axd"));
uris.Add(new Uri("GEOWMS.USAC.MMM.COM:81/WmsHandler.axd"));
uris.Add(new Uri("GEOWMS.USAC.MMM.COM:82/WmsHandler.axd"));
uris.Add(new Uri("GEOWMS.USAC.MMM.COM:83/WmsHandler.axd"));
uris.Add(new Uri("GEOWMS.USAC.MMM.COM:84/WmsHandler.axd"));
uris.Add(new Uri("GEOWMS.USAC.MMM.COM:85/WmsHandler.axd"));
uris.Add(new Uri("GEOWMS.USAC.MMM.COM:86/WmsHandler.axd"));
//uris.Add(new Uri("GEOWMS.USAC.MMM.COM:87/WmsHandler.axd"));
//uris.Add(new Uri("GEOWMS.USAC.MMM.COM:88/WmsHandler.axd"));
}
})
.TileType(TileType.SingleTile)
.IsBaseOverlay(true);
//HeatLayer Heat = new HeatLayer();
//Heat.Name = "Heat";
//Heat.IsVisible = true;
overlays
.LayerOverlay("HeatOverlay")
.Name("HeatOverlay")
.IsBaseOverlay(false)
.TileType(TileType.SingleTile);
//overlays
// .LayerOverlay("HeatOverlay").Name("HeatOverlay").IsBaseOverlay(false)
// .Layer("Heat", Heat).TileType(TileType.SingleTile);
})
.Render();
}
GeoKeyedCollection<Overlay> _overlays = map.CustomOverlays;
LayerOverlay _layerOverlay = (LayerOverlay)_overlays["HeatOverlay"];
//HeatLayer heatLayer = (HeatLayer)_layerOverlay.Layers["Heat"];
//LayerOverlay __layerOverlay = new LayerOverlay();
//__layerOverlay.Name = "HeatOverlay";
//__layerOverlay.IsBaseOverlay = false;
//__layerOverlay.IsVisible = true;
HeatLayer __heatLayer = new HeatLayer();
_layerOverlay.Layers.Add(__heatLayer);
InMemoryFeatureSource _featureSource = new InMemoryFeatureSource(this.FeatureSourceColumns(_features[0]), _features);
_featureSource.Open();
_featureSource.BuildIndex();
HeatStyle heatStyle;
heatStyle = new HeatStyle();
heatStyle.RequiredColumnNames.Add("sales");
heatStyle.IntensityColumnName = "sales";
heatStyle.IntensityRangeStart = 1.00D;
heatStyle.IntensityRangeEnd = 100000000.00D;
heatStyle.Alpha = 128;
heatStyle.PointIntensity = 512;
heatStyle.PointRadius = (double)10000D;
heatStyle.PointRadiusUnit = DistanceUnit.Meter;
__heatLayer.HeatStyle = heatStyle;
__heatLayer.Name = "Heat";
__heatLayer.IsVisible = true;
__heatLayer.FeatureSource = _featureSource;
map.ZoomToMarkers(_markers);
return (map.CurrentExtent.GetWellKnownText());