ThinkGeo.com    |     Documentation    |     Premium Support

Highlight overlay on Google Maps

Hi,


I'm testing the latest 3.0.117 Beta 2. I'n drawing shapefiles over Google Maps and I have some performance issue.


When I put a ShapeFileFeatureLayer over the map with only classbreakstyles and different ZoomLevelSet,   the application works with acceptable performance. But when I add a HighlightOverlay, in Firefox 3 the application has a high loading time and then the highlights appears with a delay, in IE7 instead the page becomes unusable.


I've attached my sample project (remove the last .zip extension on all files, the multispan archive has been made with 7zip), in the real application I need to put more than one layer over the map using difefrent ZoomLevelSet.


Furthermore I have to add graphs and click events. Am I doing something wrong? How can I speed up my application?


One last question: what about ShapeFileFeatureLayer over Virtual Earth map? What kind of projection do I have to set? Regions don't match with the VE map...


Thanks in advance.


Fabio



141-ICRDemo.zip.001.zip (195 KB)
142-ICRDemo.zip.002.zip (195 KB)
143-ICRDemo.zip.003.zip (194 KB)

Fabio,


 


It is slow because you get all the features to the HighLightOverlay from shape file, which creates the WKT of all features and send them to client. As the shapes are in client part, changing its style is fast, but you have to wait a long time until all the features are serialized and created.  You can see our sample Overlays -> “Highlight a Feature While Hovering” to get an idea.

 


You can use InMemoryFeatureLayer instead for highlighting. Add an InMemoryFeatureLayer to your LayerOverlay. Find the clicked feature and add it to the highlight layer in your map click event handler. See the code below


  protected void Map1_Click(object sender, MapClickedEventArgs e)
        {
// ......
            InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)((LayerOverlay)(Map1.CustomOverlays[0])).Layers["HighlightLayer"];
            highlightLayer.InternalFeatures.Clear();

            // Find the country the user clicked on.
            layer.Open();
            Collection<Feature> selectedFeatures = layer.QueryTools.GetFeaturesContaining(e.Position, new string[2] { "NOME", "POP_M_03" });
            layer.Close();

            if (selectedFeatures.Count > 0)
            {
                highlightLayer.InternalFeatures.Add(selectedFeatures[0].Id, selectedFeatures[0]);
            }
      
//......

            ((LayerOverlay)(Map1.CustomOverlays[0])).Redraw();
  }


 


The projection setting for Virtual Earth is the same as Google.  You can also use Proj4Projection.GetGoogleMapParametersString() to get the projection string.  The zip including shapefiles you provided seems corrupted. I tested with a shape file here and it matched fine with Virtual Earth.  I think your data should work too. 

 


Any queries just let us know.

Ben.

Seems there are some issues when posting codes in forum. just let you know &#91;2&#93 means[ 2 ], &#91;1&#93 stands for [ 1 ].



Thanks Ben for you reply. 
 I’ve changed my application to select an area when the user clicks on it. It’s not the same effect like hovering, but it’s a good solution. 
  
 About projection settings for Virtual Earth, I’ve used the same settings as Google Map (and Yahoo Map, it also works  on it): at the application startup, the layer is applied correctly on VE map, but when I zoom in and out it doesn’t render in the right place. 
  
 Tell me if you need the shape files, I’ll try to reattach it to the next message. 
  
 Thanks in advance, 
 Fabio 
  


Fabio,  
  
 That’s strange. Can you send the shape file to me?  You can send to support@thinkgeo.com and ask to forward to Ben if you don’t want to post sensitive data here. 
  
 Ben.


 Fabio,  
  
 We got the data and saw the problem. It’s because Virtual Earth has some animation before zooming in to the target extent and our Map Suite gets the map image under target extent directly. So VE and the map image will match only after the VE’s animation. 
   
 Maybe there are some settings in Virtual Earth which can turn off the animation, or there are some events that can show the shapefile map image after the animation. We are still investigating that and let you know what we found now, maybe you have a good idea how to work around this. 
  
 Ben 


Hi Ben, 
 I’ve downloaded the last beta today, the problem with Virtual Earth is solved. The animation is still annoying, but I know that it’s a VE feature. 
  
 Thanks for the solution. 
  
 Fabio

That’s great! Any queries please let us know.