Yesterday I was trying to create first mock-ups of my GPS tracker interface, and was exploring the available OpenLayers objects for drawing on a map.
I began with simple task - placing a marker on a map, on a Markers layer. I added the appropriate image to the marker, learned how to move it on a map, and added a Popup to the onclick event that opens additional info about that marker. Works great. Since I wanted this marker to represent the vehicle, the next step was going to be to populate the content of the marker's Popup using AJAX. When the onclick event occurs I'll send the marker's ID to my python script, fetch the latest data from my postGIS database and update the marker and it's popup appropriately.
But then I saw in the OpenLayers documentation that markers don't have ID attribute, and that I'll probably have to end up using vector or feature object. OK, both of them have id attribute and createMarker methods, so I'll easily transfer my Markers into Features/Vectors. After that I saw an example on the web where someone just initializes id attribute to the marker like this:
marker = new OpenLayers.Marker(new OpenLayers.LonLat(90,10),icon.clone());
marker.id = 353;
And it works fine, I can now add various attributes to my markers and use the as needed. For example:
marker.id = 353;
marker.popups_id = 382;
marker.data = "Marker for a vehicle";
So, after I've done what I wanted in the start I started wondering - what are the main reasons for these 3 different Classes if I can take Marker and fill it with various data to make it look like a feature.
Am I doing it wrong, or is there a better approach?
It seems to me that I could create my map objects using Markers only, but I don't want to regret that later if I hit it's limits.
Are there any size/performance limits and recommendations when to use Markers and when Features or is it all based on testing and refactoring as needed?
Just to add, my application will be a simple GPS tracker. So I'll be using OpenLayers to display objects, move them, animate them, show their properties and similar tasks. I'll have to support having minimal 300 active objects on a map in the same moment, and refresh their coordinates at least every 15 seconds.