Hi,

My application is a Winforms application that shows in a WebBrowser control an HTML page I generate "on the fly". That is, application writes all needed HTML and Javascript code to show the user the corresponding map with serveral pushpins at a concrete zoom level.

Of course, user can zoom-in, zoom-out and so on in the showed map. However, every 5 minutes fires a timer that writes again the HTML file (in case new pushpins must be added) and shows again the map to user. My problem is that when rewriting the HTML file, I always go back to the initial established zoom, without remembering which was the zoom the user was in.

Before generating again the HTML page, I need something to store the current zoom level (using map.GetZoom()), so that new HTML page starts at that zoom level, instead of the initial zoom level.

Therefore, where to store current zoom level so that it is accesible when generating next HTML page (new map)

Any ideas are wellcome.

Thanks very much in advance.




Re: Must mantain current zoom level when reloading map

Earthware


Hi

Does your entire map need to update, or just the pushpins

If its just the pushpins you could have a javascript function call a refresh of the pushpin data every 5 mins. You can actually call .net methods in your main application from javascript directly using "window.external.mymethodname".

However if you just want to store the zoom level as you have suggested you can call a js function from your app using "document.InvokeScript" on your browser control.

Let us know how you get on.

Brian Norman

www.earthware.co.uk






Re: Must mantain current zoom level when reloading map

Lonifasiko

Hi,

First of all, thanks very much for your reply.

As you suggested, at the moment only want to store current zoom level, so I've built a Javascript function in my HTML page that looks like this:

function GetCurrentZoomLevel()

{

if (map != null)

return map.GetZoomLevel();

else

return null;

}

Then, from my Windows application, I only have to invoke this script as you told me:

object zoom = webBrowser.Document.InvokeScript("GetCurrentZoomLevel");

This way, I've got current zoom level in my Winforms application.

Thanks very much.

Kind regards.