I want to show some coordinates in a Google map, it works fine to get it from a text file but I don't know how to access to coordinates from database.
Here the code working with a text file :
<script type="text/javascript">
var map;
var markers = [];
var mon_fichier = fichier_txt("file.txt");
var elem = mon_fichier.split(',');
var tHandleMajActors; // Handle timer majActeurs()
function initialize() {
var haightAshbury = new google.maps.LatLng(elem[0], elem[1]);
var mapOptions = {
zoom: 6,
center: haightAshbury,
mapTypeId: google.maps.MapTypeId.TERRAIN
/*mapTypeId: google.maps.MapTypeId.SATELLITE*/
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
//run realtime view
RTrun();
}
//RT MENU MANAGEMENT
function RTrun(){
movePositionMarker();
}
//RT MARKER MANAGEMENT
function movePositionMarker(){ //XXX timer
var mon_fichier = fichier_txt("file.txt");
var elem = mon_fichier.split(',');
i=0;
while (i<elem.length) {
var myPosition = new google.maps.LatLng(elem[i], elem[i+1]);
i=i+2;
addMarker(myPosition);
}
//timer: every 10 s
tHandleMajActors = setTimeout( function(){
movePositionMarker();
}, 10000);
}
// Add a marker to the map and push to the array.
function addMarker(location) {
var image = 'images/flag.png';
var marker = new google.maps.Marker({
//animation: google.maps.Animation.DROP,
position: location,
map: map,
icon: image
});
markers.push(marker);
}
The table from which I want to take coordinates is called Coordinate and has :latitude, :longitude, :date, :time, :tracker_id
Thank you for your help !