ThinkGeo.com    |     Documentation    |     Premium Support

JS markers become invisible after moveend

I have an js object that stores data. After you click to start button. they will be putted on map with window.settimeout. If you dont touch map area icons shown till moveend  event fired. If you move my map, all predefined markers become invisible.  What can be the solution?



        
  • z-index

  •     
  • wrong layer


Thanks


 



389-WebApplication1.zip (148 KB)

How can i redraw markers after moveend event. Update dont work.




 parserMap1.map.events.register('moveend', this, this.update); 



Tolga, 



You are doing very cool stuff on the map :), here we have two recommendations for you, 



1. map.panTo(lonlat) is a smooth panning with an animation that the map will move smoothly to the destination. “moveend” event will not be raised during the moving, only will be raised when it ends. If every step we raise a moveend event, that might be too often. So we recommend making the timer interval longer, for example 1000, before the “moveend” is raised. 



2. It’s a good idea to use the existing marker overlays defined on the server side, but in web edition, InMemoryMarkerOverlay and FeatureSourceMarkerOverlay do not include all the markers at one time, in fact to improve the performance, only the markers within current extent will be added. At the end of every pan, as the current extent is changed, the available markers will also be refreshed, that’s why your predefined markers become invisible. One solution is to use SimpleMarkerOverlay, all markers added on this overlay will be always on the map, even they are not in the current extent. Here is the code of it. 




SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay("vehicleLayer");
Marker startMarker = new Marker(point, new WebImage("images/3.gif"));
markerOverlay.Markers.Add(startMarker);
Map1.CustomOverlays.Add(markerOverlay);

Another way to fix this is to create a new marker layer at client, please see the code below: 


var markerLayer = new OpenLayers.Layer.Markers('vehicleLayer');
map.addLayer(markerLayer);

Let me know if you have any issues. 



Thanks, 



Ben 

 



I hope, I’ll do my best. :)  Is there any documents for layer types? Like prons and cons. 
  
 Thanks Ben.

Tolga, 
  
 We don’t have a complete manual for now so sorry I cannot provide you a systematic documentation. In fact that’s the next thing we will focus on and we will work on that very soon. Now generally we can say, layer is for server part drawing, it holds the data----FeatureSource / RasterSource and has the way of rendering ---- Styles. Overlay is rendered on client side, it can be an image generated by several layers like LayerOverlay; or it can be an image directly from 3rd part source like GoogleMapOverlay, also it can be a couple divs rendered on client such as MarkerOverlay. So when you see a layer, it must be on server part and an Overlay must contribute the client part. I think if you understand these 2 concepts, you will not have much trouble using the web edition. 
  
 Let me know if you are not sure about some topics and we are glad to provide more explanation. 
  
 Thanks, 
  
 Ben 


Thanks Ben.

My pleasure:)

Hi all,


I seem to be having the same or similiar issue. I am using the MarkerOverlayer to create markers with Dynamic Popups (have row collection data being used for content). When panning, doing some function or event, then zooming out - some of the markers become 'invisible'. Ben, I see what you are saying in your comments above. Does the SimpleMarkerOverlay have the same features as the MarkerOverlay (e.i CustomMarkerStyle, CustomPopups)? Is there a way to keep these markers from not becoming 'invisible' with the MarkerOverlay? I am not using the customoverlay, soooo... If I have to - I would have to change quite a bit in my project (because you can't use the Default overlays with the customOverlay :)  ). Do you have an example that you can share that can give me an idea of what I can do?


 


Thanks again,


Cruz



Cruz, 
  
 I couldn’t recreate the issue that some markers become “invisible” after some operations like panning and Zooming out. What I do know is that when changing the viewport, like panning the map, the “new markers” will be rendered only after you release the mouse. Can you let me know in detail how can I recreate your problem? it might be a bug. 
  
 SimpleMarkerOverlay is just a group of markers in which you need to set the style for every marker separately. It doesn’t support CustomMarkerStyle or CustomPopups like what MarkerOverlay does. As what I mentioned in above messages the markers in simpleMarkerOverlay will always be prerendered, so for example, during the panning, the marker is always on the place it should be. Please have a look at the sample Markers->UseDraggableMarkers for detail, also here is how to set the popup for one marker in a  SimpleMarkerOverlay. 
  
 
                SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay(“MarkerOverlay”);
                Marker marker = new Marker(-8922952.93266, 2984101.58384, new WebImage(21, 25, -10.5f, -25f));
                marker.Popup.ContentHtml = “Hello World”;
                marker.PopupDelay = 200;
                markerOverlay.Markers.Add(marker);
 
 So in a word, SimpleMarkerOverlay might solve your “InVisible” issue but as it doesn’t support the CustomPopups and CustomMarkerStyle, the codes will be more and the performance will be lower. It’s great if you can show us how to recreate the “invisible” problem, we may find a way to work it around and you can still use MarkerOverlay. 
  
 Thanks, 
  
 Ben

Ben, hope you don't hate me yet! J/K


Attached is an example of the 'invisible' issue. To reproduce, zoom into one of the highlight features so that a few are rendered outside of the default extent. Click on the feature just to activate an event. When postback is complete, zoom back out and the features that were rendered outside the extent will no longer have markers. If I check the Map.MarkerOverlayer count of features it still shows the initial amount drawn but do not show all of them.


Let me know what you find out....


 


Thanks again,


Cruz



473-WebMap.zip (133 KB)

Cruz, 
  
 I’m about to do that but then you provide a great sample. :-) Thanks very much for the sample as based on that, we found a bug in our current version. We are trying to fix it in the coming version and now to work around, please change your codes as following.  
 
markerStyle.ValueItems.Add(new MarkerValueItem(_ProjectList[i].SubdivCode, new PointMarkerStyle(new WebImage(“theme/default/img/marker_blue.gif”, 21, 25), new CustomPopup(_ProjectList[i].SubdivCode + i + j, projectFeature.GetBoundingBox().GetCenterPoint(), PopupContent(), 280, 75, false, true, 1))));
 
 Let me know if you have more issues. 
  
 Thanks again! 
  
 Ben