ROS node lat and long topics in Google Maps Javascript

asked 2020-05-02 19:02:33 -0500

Primo gravatar image

updated 2020-05-02 22:03:49 -0500

Thomas D gravatar image

Hello, I have two nodes running, one gives me my latitude, the other gives me my longitude. I am trying to use those two Floats in my google maps JS project and moove my marker depending on these nodes.

var latitude = parseFloat(document.getElementById("latitude").innerHTML);
var longitude = parseFloat(document.getElementById("longitude").innerHTML);
var myLatLng ={lat: latitude, lng: longitude};

function initMap() {
    map = new google.maps.Map(document.getElementById('map'), {
        center: myLatLng,
        mapTypeId: 'satellite',
        zoom: 15,

     var marker = new google.maps.Marker({
         position: myLatLng,
         map: map,
         title: 'robot.',

I get the lat and long in two html divs.

If anyone could help, thank you.

edit retag flag offensive close merge delete