This project has moved and is read-only. For the latest updates, please go here.

Refresh Map

Topics: SharpMap v0.9 / v1.x
Nov 14, 2010 at 2:01 PM

My application is updating the geometries positions (which are contained in theirs appropriate layers). what is the best way to refresh the map, for viewing the updated geometries positions, without to decrease the map performance ?.


Thanks Ahead


Nov 15, 2010 at 9:06 AM

hello snoriani,

could you explain a bit more how your application updates geometries?

Cheers FOBermaier

Nov 15, 2010 at 8:36 PM
Point X Position = (X,Y)
Point X is in Layer Z
Point X is displayed on map (with an icon of a car)
For I = 0 to 1000
Point X Position = (X++, Y++)
Now, What is the best way to see the car moving on the map. is to refresh the map after every iteration? Like this:
For I = 0 to 1000
Point X Position = (X++, Y++)
This way is very slowely. I need a better way.
Nov 16, 2010 at 11:00 PM

hello snoriani,

I just submitted code that can be used with variable datasources, variable in terms of that the data is changing.

Look at the WinFormSamples project, there is a

  • TileLayerWithVariableLayerCollection function in TileLayerSample.cs that creates a map showing busses and trolleys of Vilnius, The data is retrived via http
  • ShapeFileSampleOSM.cs has a very basic use

Hth FObermaier

Nov 21, 2010 at 11:05 AM
How can i find this version?
Thanks Ahead.
Nov 21, 2010 at 12:51 PM
Is the following code (Copied from SharpMap) determines the map refresh rate:???
map.VariableLayers.Interval = 5000;

If so,
How can i set the map to be refresh every 0.001 seconds or even less ???. actually i need to refresh the map on any movement of the vehicles like in the bus example
In this case the map is updated very slowly.
Nov 22, 2010 at 8:28 AM

hello snoriani,

ATM VariableLayerCollection requeries its layers every interval, e.g. 5000 = every 5 seconds. So if you want to update every 0.001 sec you'd have to set the interval to 1.

Depending on the size of your updateable data (how many cars do you track) some of the queries wouldn't be executed since it is not done processing the last request.

Keep in mind that the human eye is "only" capable of processing 24 images per second, so if you want a smooth apperance you only need to refresh every 40 ms.

Where does your data come from, do you get an event triggerd once it arrived? In that case you could modify VariableLayerCollection to handle those events and force a requery.

Hth FObermaier

Nov 23, 2010 at 8:50 AM
I will try to explain the problem more clearly:
I have a a list of 1000 car's positions in a cm acurracy. Lets say that the car is driving from point A to point B in 100 seconds. in the general case i just need to iterate the list and to refresh the map after every position update.
now in a more complecated case i need to display the same car's path (A -> B) but in a factor of 100. it means that i need to display the same path (A -> B) but instead 100 seconds the time shall be 100/100 (1 second).
The problem is that i can not refresh the map after every position update becuase that the refresh is to slow and the updates can not be in time limitation. The 1000 positions updated causing 1000 refresh map and it can not be done in 1 second.
How can i solve it ?
Thanks Ahead.
Nov 29, 2010 at 8:45 AM

Hello snoriani,

I've setup a sample like this:

  • Export route from google earth as kml.
  • Split route into ~5500 points.
  • Store points along with index in PostGis database
  • Modified the PostGis provider to update the index every 10ms and overrode the GetGeometriesInView function to retrieve the current Point and a Linestring of the last 500 points. The PostGis provider returned a simplified version of it.

I added a VectorLayer using this provider to the VariableLayerCollection and set the update interval to 24 ms. Without any noticable performance I could see how the car and the Linestring were following the path.

I won't add the sample to the trunk, since it is very specific. If you are interested in the sample, just let me know.

Cheers FObermaier


Dec 3, 2010 at 9:32 PM

Hello FObermaier

I'm interested in the sample.

I can add a VariableLayer to the AjaxMap web control, but i can't add a LabelLayer for the VariableLayer or get the VariableLayer using the GetLayerByName function.

How can I get the VariableLayer, to add a LabelLayer on it or to unload the layer from the map?

Thanks and sorry for the bad english.

Dec 3, 2010 at 10:19 PM

I'm getting the VariableLayer name with this function.

VariableLayers are great for tracking vehicles !


public SharpMap.Layers.ILayer ObtenerLayerVariablePorNombre(string nombre_layer)
        SharpMap.Layers.VariableLayerCollection coleccion = ajaxMap.Map.VariableLayers;
        SharpMap.Layers.ILayer layer = null;
        foreach (SharpMap.Layers.ILayer ly in coleccion) {
            if (ly.LayerName == nombre_layer)
                layer = ly;
        return layer;
Dec 4, 2010 at 9:05 PM
carjona wrote:

Hello FObermaier

I'm interested in the sample.

I can add a VariableLayer to the AjaxMap web control, but i can't add a LabelLayer for the VariableLayer or get the VariableLayer using the GetLayerByName function.

How can I get the VariableLayer, to add a LabelLayer on it or to unload the layer from the map?

Thanks and sorry for the bad english.

carjona, I'll send it to you by monday.

Thanks for your proposal, I'll look into it. Maybe you can setup a small sample with variablelayercollection with ajaxmap that we could add to the repository?

cheers FObermaier

Dec 6, 2010 at 2:36 PM


I will setup the sample when i get some time. I'd love to help to the project with something. How can I submit the sample?

Now I can add the VariableLayers to the AjaxMapControl successfully and setup the Interval to 10000, but the data is updated only when I move around the map (zoom in/out or pan). I guess that I have to use a Timer to manually refresh the map every 10 seconds. Is that the way to do it ?



Dec 6, 2010 at 2:44 PM

Hello carjona, the WinForms MapImage control picks up


event. This in turn just gets the updated layers of the map and merges the result with the static part. I don't know if it can be done like that on the web side.

Hth FObermaier

Dec 7, 2010 at 11:19 PM


Unfortunately it can't be done like that on the web side for the AjaxMapControl. (at least I could not do it)

I could get every VariableLayerCollectionRequery event which is fired on Interval Timer elapsed and refresh the page.

Another way to do it is to add static layers to the ajaxMap Control and set a timer to refresh the page.

Do you think is there a better way to refresh my variable data on the web side?  (it's a database with gps location of vehicles)

I was searching this forum and apparently there is no support for the AjaxMapControl. I'm interested in this control because I have already achieved to load shape files, dxf files, sql server spatial and oledb points. I'm a developer from a Telecommunications company in Bolivia and we want to use this tool inside our LAN because we have already the base carto (.shp) and we can publish it to users that do not necessarily have an internet connection.

Please give me some advice, thanks



ajaxMap.Map.VariableLayers.VariableLayerCollectionRequery += new SharpMap.Layers.VariableLayerCollectionRequeryHandler(OnRequery);


void OnRequery(object sender, EventArgs e)
          // RefreshPage();


Dec 9, 2010 at 7:48 PM

I think it's not going to work this way, the VariableLayers.Interval timer won't let me refresh page because is loosing the HttpContext.Current on the page, couldn't do it via javascript either. 


Jan 2, 2011 at 10:18 AM
How can i display geometries with a required rotation for each one of them. The geometries are of a Point type and are related to an icon.
For example:
A bus driving in its path and needs be displayed with its required rotation on the map for each point in its path.
Thanks Ahead.

Jan 3, 2011 at 1:00 PM

Hi snoriani

You can look at ExampleCodeSnippets project and use the GetRotatedSymol function in Theming.cs class.