user3479343
user3479343

Reputation: 29

GPS coordinates on Google maps with JavaScript

I'm building a google map page that will act somewhat like a database for 4 or 5 gps devices around the country. the gps devices that i am using will have their own ip address within a router they will be connected to. to access the lattitude you would input EXAMPLE: 10.10.10.222/server/latitude.cgi and that would access a file with just the text of the lattitude. My problem is that i don't know how to apply that into a google map javascript, does it just reads the text in the file automatically or i have to assign it to read the text? i can't test it for a few days so rather than get bogged down i figured id ask here.

The page describing the gps devices is here, along with how the information is pulled from it and how to call it.

here is my javascript with lattitude and longitude placeholders of (47,-100):

{
    var map = new google.maps.Map(map_canvas, map_options);
    var point = new google.maps.LatLng(47, -100);
    var marker = new google.maps.Marker({
        position: point,
        map: map,
        icon: 'PointMarkerON.png',
        title: 'Site 1'

    })}
}

Upvotes: 0

Views: 320

Answers (1)

Paul Giragossian
Paul Giragossian

Reputation: 375

You have to request gps url before calling Google Maps API.For example, if jquery is there :

$.get( "http://10.10.10.222/server/latitude.cgi", function( latitude ) {
    $.get( "http://10.10.10.222/server/longitude.cgi", function( longitude ) {

        var map = new google.maps.Map(map_canvas, map_options);
        var point = new google.maps.LatLng(latitude, longitude);
        var marker = new google.maps.Marker({
            position: point,
            map: map,
            icon: 'PointMarkerON.png',
            title: 'Site 1'
        });
    }); 
});

Upvotes: 1

Related Questions