ThinkGeo.com    |     Documentation    |     Premium Support

Map refresh

Hi


I have two related questions:


1)


I have build my own TOC control with some project specific information which also allows the user to control the visibility of the layes added to the StaticOverlay collection. When the user checks on or off a layer I update the text in a HiddenField that I can get hold of server side. In need of better ways I do a Map1.SetCenter(Map1.GetCenter()); to force a postback. In my MapExtentChanged event handler server side I can now enable or disable the layers, Question one is, is there a better way of forcing a refresh of the map?

2)



 


Doing above requires me to have an MapExtentChanged event defined. When this event is defined even though there is nothing in the event handler it causes the map to refresh in a much less nice way as if it's not there. If I dn't attach the event handler, zooming causes the zoom to happen immediately first with the magnified bitmap which is then updated with the rerendered tiles. This is a quite smooth transition. When the event handler is defined the image is first magnified, then the container is blanked out with white and first then the rerendered tiles appear. This gives a very bad clickering experience. Question two is, is there a way of having a map extent changed event and the same smooth experience as if there is no event handler defined?


Thanks in advance


Franz Thomsen



Hi Franz, 


I think you want to make your own layer switcher and create the stretch effect when zooming in/out, is that right?  If that’s the case, we recommend not using the extent changed event, here is a better solution for you.
 
Thanks,
 
Ben

367-Post5247.zip (101 KB)

I get an error:  
 Map1.StaticOverlay.Layers[layerName].IsVisible = layerInfos[layerName];                      //error: The given key was not present in the dictionary. 
 Please help me!

Why can noy I post a new topic!

Why I can not post a new topic? 
  
 I want find a place by type name into textbox and click submit and my map will show the place i want in the center of the screen. Please help me! 
 Thanks all!

Truong, 


I’m not sure why you cannot post a new topic. You still have that issue? What did you see when creating a new post; can you provide some snapshot?
 
About the “given key was not present” exception, that’s because the key layerName has not been added to the StaticOverlay. Please check the code if you forget to add a layer with that key, also please use Map1.StaticOverlay.Layers.Contains(layerName) to make sure the key exists before you are using it. 
 
Your last requirement can be generally divided into 2 parts, first getting the position from the input address, 2nd, Center the map to that position. The 2nd part is easy that you can simply call our API “Map1.ZoomTo(PointShape center, double scale)” and pass in the center point. The 1st part is a bit tricky though.
 
If the place you are inputting is always within US, I suggest using our Geocode to get the position. Here is GeoCode online demo and you can have a general idea how it works. onlinedemos.thinkgeo.com/geocodeusa/
If the place you are inputting is not within US, or you will use some custom data for the locating, you need to do it yourself. For example, you have a city layer and when inputting a city name “Lawrence”, for example, you want to center that city. You need to loop through all the records and find the right feature with the name “Lawrence”, and then get its position. It’s not too difficult to locate a city, but will be much more complicated to locate a road. 
 
 Let me know how you think about it and your concrete requirement.
 
Thanks,
 
Ben

Ben, 
 Thanks you!I will pratice it. See you agian. Thanks again for you advice!

Ben, 
 Can you give me some code about find position by name. Thanks! 
 This is my code: mediafire.com/?rozkyolygv4 


Truong,


I cannot open the link you provide. but anyway, here is a sample for you and I think you can get everything you need.


Thanks,


Ben 



392-GetPositionByName.zip (10.9 KB)

There are some errors I get when debug your example: 
  Error 1 ‘ThinkGeo.MapSuite.WebEdition.Map’ does not contain a definition for ‘ZoomTo’ and no extension method ‘ZoomTo’ accepting a first argument of type ‘ThinkGeo.MapSuite.WebEdition.Map’ could be found (are you missing a using directive or an assembly reference?) 
  
 Error 2 ‘ThinkGeo.MapSuite.WebEdition.Map’ does not contain a definition for ‘ClientZoomLevelScales’ and no extension method  
 ‘ClientZoomLevelScales’ accepting a first argument of type ‘ThinkGeo.MapSuite.WebEdition.Map’ could be found (are you missing a using directive or an assembly reference?) 
  
 Error 3 No overload for method ‘Add’ takes ‘1’ arguments   =============  ((InMemoryFeatureLayer)Map1.DynamicOverlay.Layers[0]).InternalFeatures.Add(selectedFeature); 


What method to get position of feature?

Truong, 
  
 You are still using the Beta Version I think. Please update to the latest version (3.1.16) and have another try. 
  
 A feature is composed of one (for point) or more points (for polyline and polygon) and every point is within World Coordinates. Can you let me know more what you mean by "position of feature", the screen position or world position, the rightleft points or some "center point" using certain algorithm or something?  
  
 Thanks, 
  
 Ben 


Ben, 
 Thank you very much! 
  
 We have: Feature selectedFeature = new Feature(); 
 so I want to get its position, it’s screen position. 
  
 And I want my map return to original state after i do something,exp: set a marker,draw a line, apply a custom style… what methods ? 
  
  


Truong,  


If you only have Feature selectedFeature = new Feature();  you cannot get its position as that feature doesn’t have any data. Here as following is a sample how to get the screen coordinates of a point feature. 
 

 

Feature feature = new Feature(0, 0);
ScreenPointF screenPointF = ExtentHelper.ToScreenCoordinate(Map1.CurrentExtent, feature, (float)Map1.WidthInPixels, (float)Map1.HeightInPixels);

I’m not sure what you mean by “original state”, for example, after setting a marker, we remove the marker and get to the “original state”? Can you provide more information about your scenario?
 
Thanks,
 
Ben

Ben,  
 Can you send me some documents about ThinkGeo and Map Suite Web product? Iwant to intro it to my friend in Viet Nam. I want to know Map Suite Web about: requirements system, technology,…

Ben,  
  
  after setting a marker, we remove the marker and get to the “original state” ==> Yes, i want that! I can not to remove the marker after add it into my map! 
  
 Can you send me some documents about ThinkGeo and Map Suite Web product? Iwant to intro it to my friend in Viet Nam. I want to know Map Suite Web about: requirements system, technology,… 
  
 Thanks!

Truong, 


We have 3 kinds of Marker Overlays, SimpleMarkerOverlay, InMemoryMarkerOverlay and FeatureSourceMarkerOverlay. FeatureSourceMarkerOverlay consumes a FeatureSource and it’s not supposed to add / remove a marker. Here we talk about how to remove feature from InMemoryMarkerOverlay and SimpleMarkerOverlay.
 
For SimpleMarkerOverlay

               Marker a = new Marker(0, 0, new WebImage("/theme/default/img/marker_blue.gif"));
                a.Id = "id1";
                SimpleMarkerOverlay simpleMarkerOverlay = new SimpleMarkerOverlay();
      // Add the marker to the overlay and rendered
                simpleMarkerOverlay.Markers.Add(a);
                // Remove the Marker
                simpleMarkerOverlay.Markers.Remove("id1");

 
For InMemoryMarkerOverlay

       Feature b = new Feature(1, 1);
                InMemoryMarkerOverlay inMemoryMarkerOverlay = new InMemoryMarkerOverlay();
                // Add the Marker and Render the layer
inMemoryMarkerOverlay.Features.Add("id2", b);
                inMemoryMarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage = new WebImage("/theme/default/img/marker_blue.gif");
                inMemoryMarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// Remove the marker
                inMemoryMarkerOverlay.Features.Remove("id2");

You can see simpleMarkerOverlay is really simple, just add the markers and it will render. However it’s not supposed to have many markers as we didn’t have the optimization for its performance. For example, if I added 10 Markers to the map but I zoom in to a small extent and only one marker is within the viewport, all the 10 markers will still be rendered. InMemoryMarkerLayer is a “formal” layer which supports zoomLevel and has the performance optimization, so most of the time, we recommend to use this one.
 
We didn’t have a comprehensive manual so far and we will work on it pretty soon. Generally, Web Edition is a pure .NET component and support all the mainstream Microsoft Systems (XP/Vista/2003, X64/X86). Here we have documentation for all the APIs and we have some white papers for some specific topics, I hope that will be helpful and hope your friend will like it too. :)
 
 
The API documentation:
gis.thinkgeo.com/mapsuite3docs/webedition/
 
The White Papers:
gis.thinkgeo.com/Support/DiscussionForums/tabid/143/afv/topicsview/aff/20/Default.aspx
 
Thanks,
 
Ben

Ben, 
 Have algorithms to find road from this position to other in Map Suite Web Edition? 
 Thanks!

Regular Expression rendering

Truong, 
  
 By “find road from this position to other”, you mean routing? We don’t support routing now but definitely it’s in our plan.  
  
 And Yes, we support regular expression rendering using the built in RegexStyle, you can see how to use it from the sample Styles->DrawFeatureBasedOnRegularExpression. 
  
 Let me know if you have any issues. 
  
 Ben