Brutile with ajaxMap control

Topics: SharpMap v0.9 / v1.x, Web Controls
Editor
Dec 21, 2010 at 3:24 PM

Hi all

Is it a good choice to load brutile tile layers as background inside the ajaxMap control ?

I have a web site using the ajaxMap control to display shapefiles, dxf and database info based on lat/lon. I'm not using the maphandler.ashx, instead store the ajaxMap.Map object into cache and load it from cache, to avoid calling InitializeMap on every map refresh.

Now I want to add GoogleMaps as background image to my map, I did this using Brutile TileLayers but the map is displaying too slow. 

Please I need some explanation on how to use tiles and brutile to make the map display faster. 

Thanks

public static Map InicializarMapa(string poblacion, Size size)
    {
        HttpContext.Current.Trace.Write("Inicializando mapa...");
        //Initialize a new map of size 'imagesize'
        SharpMap.Map map = new SharpMap.Map(size);
	
TileLayer tileLayer = new TileLayer(new GoogleTileSource(GoogleMapType.GoogleMap), "TileLayer - Google");
map.Layers.Add(tileLayer);

        map.BackColor = Color.WhiteSmoke;
        map.MinimumZoom = zLevel5;
        map.MaximumZoom = zLevel1;

        map.ZoomToExtents()
        map.Zoom = map.MaximumZoom;

        HttpContext.Current.Trace.Write("Mapa inicializado");
        return map;
    }

 

protected void CargarMapa(string poblacion)
    {
        ajaxMap.UseCache = true;

        //--- Variable auxiliar, para obtener el mapa guardado en caché si se encuentra
        SharpMap.Map mapa_aux;
        //--- Solo se ejecuta la primer vez que se carga la página
        if ((!Page.IsPostBack) && (!Page.IsCallback)) {
            ViewState["rcache"] = RandomString(8);
            ajaxMap.FadeSpeed = 15;
            ajaxMap.ZoomSpeed = 15;
            //ajaxMap.ResponseFormat = "MapHandler.ashx?Width=[WIDTH]&Height=[HEIGHT]&Zoom=[ZOOM]&X=[X]&Y=[Y]&POB=" + poblacion;
            // Para habilitar el evento click cuando el control tiene el foco
            ajaxMap.Attributes.Add("onfocus", ajaxMap.EnableClickEventMethodName + "(); " + ajaxMap.ClientID + "Obj.container.style.cursor = 'auto';");
        }
        //--- Obtener el mapa guardado en caché
        mapa_aux = (SharpMap.Map)Cache.Get((ViewState["rcache"].ToString()));
        if (mapa_aux == null) {
            ajaxMap.Map = MapHelper.InicializarMapa(poblacion, 
                new System.Drawing.Size(ancho, alto));
        }
        else {ajaxMap.Map = mapa_aux;}
        //--- Insertar el nuevo mapa en caché
        if (ajaxMap.Map != null) {
            Cache.Remove(ViewState["rcache"].ToString());
            Cache.Insert(ViewState["rcache"].ToString(), ajaxMap.Map);
        }
    }

Coordinator
Dec 22, 2010 at 8:55 AM

Hello carjona,

the problem is, that the server generates the whole image and when it is finshed sends it to the client.

For more speed, you will probably need to get the client to render the tiles, but I don't know how to do that or even if it is possible at all.

Paul den Dulks - sharpmap based - Silverlight MapsUI control might be a source of inspiration.

Hth FObermaier

 

Editor
Dec 22, 2010 at 3:11 PM

Hello FObermaier

Thanks for the answer, I really appreciate your help.

I'm not sure if I'm going in the right direction. I'm developing a web application for multiple purpose in my company, the main requirements are:

  1. Display geographic information from different data sources (ShapeFile, AutoCAD, Database lat/lon information, SQL Spatial)
  2. Tracking GPS vehicle locations.
  3. Search and zoom to features.
  4. Get feature data for clicked point.
  5. Measure distances, draw geometries.

I'm using v0.9 sharpmap's ajaxMap Control.

I decided to use this tool because we have already base carto for the interest area in .shp format (blocks, parcels, street names, etc) and need FAST map display for LAN clients (they may not have an internet connection) 

So if it isn't possible to render tiles on client side using the ajaxMap control, maybe i'll desist on showing google maps as backgroung, it would be nice but not mandatory. 

I'm now trying to compile Silverlight MapsUI and Brutile-SL, so far looks cool, but before going deeply into it I have to analyze if ajaxMap control is the best choice for my project, since apparently nobody else is using this control.

What do you think about it? 

 

Editor
Dec 30, 2010 at 3:59 PM

Do you know if MapsUI have the functionality needed to achieve the requirements for my project ?

I'm asking because I wasnt able to compile Brutile-SL and MapsUI yet.

Thanks,  

Coordinator
Jan 1, 2011 at 10:38 AM

Hello carjona,

I have not been able to look at mapsui very much. but i assume you can do that. Paul is probably on holiday break and will be back soon. He told me that he will be working intensively on mapsui/brutile the first quarter of 2011.

Hth FObermaier

Editor
Jan 4, 2011 at 3:14 PM

Hello Fobermaier

I'm very interested in MapsUI so I'll wait for Paul to come back.

Thanks for your attention.