Code:
|
<script></script>
<script></script>
<script>
// Group to receive data from
var groupName = 'Ortung';
var lastUpdated = new Date();
markerDictionary[username] = marker;
map.addOverlay(marker);
}
marker.gpsGateUser = user; // make user accessible for the infowindow click-event
marker.setLatLng(point); // update position
}
}
</script>
|
Code:
|
<div></div>
<a href="http://gpsgate.com/" id="gpsgate" alt="gpsgate tracking" target="_blank">
<img src="http://apps.gpsgate.com/images/ggc_small.gif">
<span>
GPS Tracking
</span>
</a>
|
PHP:
|
<?php <HEAD> <script></script> <script></script>
<script>
// Group to receive data from var groupName = 'Ortung'; var lastUpdated = new Date();
// Get only users online since last week var lastOnlineThreadsHoldMinutes = 10080;
// Check for position updates each 10sek var updateIntervalMS = 10000;
var userDictionary = {}; var markerDictionary = {};
var map = null;
function load() { map = new GMap2(document.getElementById("map"));
// Add zoom/pan & type controls map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(49.99999999999999, 10.000000000000004), 1); map.setMapType(G_NORMAL_MAP);
// init the last update time stamp lastUpdated = new Date(lastUpdated.getTime() - lastOnlineThreadsHoldMinutes * 60000);
// start polling for positions getUsers(); }
function getUsers() { GpsGate.Server.MyService.getUpdatedUsersInGroup(groupName, lastUpdated, function(result) { // Set last update to the time when the query was executed on the server // this will make next call to only get users with new positions since this call lastUpdated = new Date(result.queryTimeStamp.getTime() - 5 * 60000);
// Iterate through the result of gateUsers for (var i = 0; i <result> 0) { // Repaint the map with new positions repaintMap(); }
// make a new call to the server in 10sek setTimeout(getUsers, updateIntervalMS); } ); }
function repaintMap() { for (var username in userDictionary) { // Get the user from dictionary var user = userDictionary[username];
// Get the latest position from the user var lat = user.trackPoint.position.latitude; var lng = user.trackPoint.position.longitude; var point = new GLatLng(lat, lng);
var marker = markerDictionary[username];
if (marker == null) { marker = new GMarker(point);
// Add InfoWindow when clicking on marker GEvent.addListener(marker, "click", function() { var user = this.gpsGateUser;
var htmlString = "<div><strong>Username: </strong>" + user.username + "<br>" + "<strong>Last updated pos:</strong>" + "<br>" + user.trackPoint.utc.toLocaleDateString() + "<br>" + user.trackPoint.utc.toLocaleTimeString(); + "</div>";
this.openInfoWindowHtml(htmlString); } );
markerDictionary[username] = marker; map.addOverlay(marker); }
marker.gpsGateUser = user; // make user accessible for the infowindow click-event
marker.setLatLng(point); // update position } } </script>
</HEAD> ?>
|