ThinkGeo.com    |     Documentation    |     Premium Support

Attach Javascript function to marker click event

Hi Howard,


Thanks for your response.


Which layer has a better performance when rendering many objects on the map, InMemoryMarkerLayer or HighlightOverlay?


Thanks.


Best Regards,


YV



YV, 
  
 HighlightOverlay will download all the features from server side to the client side, InMemoryMarkerLayer will draw the features on the server and just transfer the rendered image to map, so you can see the InMemoryMarkerLayer has a better performance.  
  
 Thanks, 
  
 Ben

Hi Ben, 
  
 Thanks for your response. 
  
 Best Regards, 
 YV

That’s my pleasure, YV. :)

Hi, 
  
 I have one question regarding the performance of the InMemoryMarkerLayer.  
  
 Currently I’m plotting 500 plus markers on the InMemoryMarkerLayer. The map will refresh itself and replot these 500 markers in a short interval. I have removed the popup for the markers to make the refresh complete faster. The performance is better comparing to the marker with popup but the customer is still not satisfied yet. 
  
 Is there other way to enhance this further? 
  
 Will the Silverlight version or the Desktop version of Map control give a better performance for this kind of situation? 
  
 Best Regards, 
 YV 


Hi YV, 
  
 You know, Marker is a DOM tree node displayed on the client side; the larger the DOM three is, the lower performance the client have. The core resolution is to reduce the count of markers displayed in one viewport. 
  
 I have two recommendations for you here. 
 1. We have “SuppressingGridSize” property to set a invisible grid on the map, the bigger the size you set the more markers will be suppress; for example setting the size to 50;  
 Marker is a point shape on the map which can trigger event and hover popup. That’s the difference between marker overlay and layer. If there too many markers crowd together, it’s hard to be clicked and trigger the click event on the correct marker, so suppress the count of marker is an easy option for you. 
  
 2. Use InMemoryFeatureLayer instead of InMemoryMarkerOverlay instead. In this way, the markers are rendered on the image and the DOM tree just maintain only one node which can make the performance fine.  
  
 We are now investigating the Clustering markers which may integrate in our future version. 
  
 Silverlight and Desktop edition has better performance; we have an installed sample in both Silverlight and Desktop edition which you can find under “\Samples\Features\RefreshPointsRandomly.xaml.cs” in Silverlight and “\CSharp Winforms How Do I Samples\Dynamic Shapes\RefreshPointsRandomly.cs” to show it, please feel free to try. 
  
 Any questions please let me know. 
  
 Thanks, 
 Howard

Hi Howard, 
  
 1. I can’t find the “SuppressingGridSize” from the API Documentation. Which object does this property belong to? 
  
 2. I have replaced the InMemoryMarkerOverlay with the InMemoryFeatureLayer. The performance gain is not so significant and it can’t trigger event and hover popup. 
  
 3. For the Desktop version, I can’t find the Marker Layer, only InMemoryFeatureLayer. Is there any plan to implement the marker layer? 
  
 4. For the Silverlight version, the sample “RefreshPointsRandomly” is using InMemoryFeatureLayer and the points position are updated on the client side (simply by increment and decrement the current position). In my application, the points position are updated from the database. If I use InMemoryMarkerLayer and using Web Service to retrieve the points position from the database, will the Silverlight version perform better than the Web version? And also, will the Silverlight version suffer the same performance degradation when there are many markers? 
  
 Thanks. 
  
 Best Regards, 
 YV

YV, 



1.    “SuppressingGridSize” is supported in InMemoryMarkerOverlay and FeatureSourceMarkerOverlay. You may not use our latest version 3.1.124. We have a online API documentation which you can find at:

gis.thinkgeo.com/mapsuite3docs/webedition/

Also here is how to use it.inMemoryMarkerOverlay.SuppressingGridSize = 50;


2.    Could you tell me how many markers exists in one viewport normally in your application? Technically, using MarkerOverlay effects more performance of Client’s Web browser’s performance while using InMemoryFeatureLayer costs more time for rendering. If using InMemorymarkerOverlay is not very compatible for you, please try “SuppressingGridSize” first, it’s complicate to use JavaScript and callback stuff.



3.    Desktop may not have this plan to add marker layer; for point layer is marker layer in Desktop edition; it does anything which marker overlay can. In web edition, the implement is a little difficult for normal user, so that we wrap it and expose this method for easily using.



4.    Silverlight Edition doesn’t support MSSQLFeatureSource by now which will be enhanced in the further version, you need to get the data to the client by web service or WCF first and then and into the InMemoryMarkerOverlay; the performance is good as the sample. General speaking, Silverlight still maintains a DOM tree on the client-side which means the more DOM tree nodes the lower performance you get; but it’s much more better than web which you can verify in our samples.



If you have any questions please let me know.



Thanks,

Howard



Hi Howard, 
  
 Thanks for the suggestions. 
  
 Best Regards, 
 YV

YV, 
  
 You are welcome; please let me know if you have more questions. 
  
 Thanks, 
 Howard

Hi all, Iam a newbie. 
 I have a scenario: "I have a Vessels Monitoring System (VMS), when a vessel is detected by VMS, in Map will appear a new icon of this vessel with longtitude and latitude. When ueser click on icon, system responses the information of selected vessel. End user can also view the distance between two vessels". 
  
 Plz: Recommend me a solution!

Hi, Duong,


First of all, we have marker; secondly, marker supports click event; thirdly  marker is posited by a PointShape which can help you get the distance. Your scenario can be satisfied by these three conditions. We have online demoes for them, please check the source code.


1, How to use MarkerOverlay.

websamples.thinkgeo.com/webe...arker.aspx


2, How to add click event on marker.

websamples.thinkgeo.com/webe...arker.aspx

 

3, How to find the distance.

websamples.thinkgeo.com/webe...oints.aspx

Please see the following code:double distance = fromMarker.Position.GetDistanceTo(toMarker.Position, GeographyUnit.DecimalDegree, DistanceUnit.Kilometer);




Hope it helps, if you have anything questions please feel free to let me know.


Thanks,

Howard



Thanks Howard alot!!! 
 I’ll try, hope to get more support. 
  
 Thanks again!

Duong, 
  
 You are welcome; please let me know if you have more questions. 
  
 Thanks, 
 Howard

Hi Howard, 
  
 My system is realtime monitoring but deployed on web app, vessels will be added, updated dynamically and online. Action applied for Marker using PostBack, it is not very suitetable.  
 Plz recommend me some solutions! 
  
 Thanks Alot.

Duong,



I think to avoid Postback, the only way is using AJAX. Here are two ways to satisfy your scenario. 



1.    Putting map into update panel and setting a timer to refresh; it’s simple and can be implemented by the code-behind. In this way the web page will go through most of its life circle, so the performance is a little bit better than post back. Also it’s the easiest way to go.



2.    Implement AJAX; use JavaScript and server-code to implement your scenario. It transfers less data to the client side and it’s better than the first one.

Generally speaking, you need to serialize the real-time markers to a string ? transfer the string to client side ? Parse the string to the marker objects ? add them into the map.



Here is an old post for how to add markers dynamically by JavaScript which is just one idea; you can try many solution using AJAX.

gis.thinkgeo.com/Support/Dis....aspx#5078



If you need any assistance, please let me know.



Thanks,

Howard



hi,



how would it be the callback function you talk about in order to send and recieve information with Ajax without make any postback or

Hi Rodrigo,



The attached sample uses the callback to get markers in server side and then display them in the client side. It’s the detail on the second way Howard mentioned above, please check if it is what you are looking for?



If more questions, don’t hesitate to let us know.

Regards,

Troy

Post5327.zip (192 KB)

Perfect 
  
 Thank you

Hi Rodrigo, 
  
 Great, please feel free to let us know if you have more queries. 
  
 Thanks, 
 Howard