#30 Click on fleet Pushpin opens vehicle map (With solution)

open
nobody
None
5
2011-09-12
2011-09-12
YanXu
No

Hi,

I've just implemented a functionality the opens the detailed route map view of a device/vehicle when clicked on the last location pushpin in fleet map view. If you are monitoring a fleet and you see a vehcile at a strange location e.g., then you might want to view the detailed route that the vehicle has taken.

This is actually quite easy to implement. There are two JS files that need to patched:

jsmap.js:

Whitin the "jsmParseXMLPoints()" method, there are already the following two lines:
/* add type/typeID */
evRcd.type = type;
evRcd.typeID = typeID;

add this one line:
evRcd.isFleet = isFleet;

OpenLayer.js:

Within the "JSMap._addPushpin()" method, there are the following lines:
ppMarker.events.register("mouseover", ppMarker, function(event) {
//alert("Over pushpin!");
self._showPushpinPopup(pp);
});
ppMarker.events.register("mouseout", ppMarker, function(event) {
self._hidePushpinPopup(pp);
});

add these lines:
var isFleet = pp.evRcd.isFleet;
var typeId = pp.evRcd.typeID;
if(isFleet && isFleet==="true" && typeId) {
ppMarker.events.register("click", ppMarker, function(event) {
location.href = './Track?page=map.device&device='+typeId;
});
}

Two comments on this implementation:
1.) There is probably a better way to get the information if this is currently a fleet map or vehicle map being displayed. I just wanted to avoid the device push pins being clickable as well, This should only work on the fleet map.
2.) The hardcoded URL is quite ugly. There is probably a better way to get the device map URL. The problem is that the "MAP_UPDATE_URL" variable on fleet map page contains the fleet map url which is not what I want.

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks