Hi frendz,
In my vehicle tracking project, I need to draw the route (polyline) of my vehicle in google map. When the vehicle is moving away from that route, it should give alert msg.
So how to specify the route line on google map?

Member Avatar for diafol

Have you had a look at the Google Maps API?

Have you had a look at the Google Maps API?

Yes Ardav, I used the google map API through out project. I got the code only to draw the polylines with set of latitude and longitude points. But I need to track whether the vehicle is moving on that line or not. Now i'm searching for that only.

how to generate latitude and longitude points by drawing lines on google map using javascript?

Member Avatar for diafol

How are you receiving the vehicle's data? Which format?

How are you receiving the vehicle's data? Which format?

latitude and longitude points as seperate column in database like this.

[B]latitude [/B]         [B]Longitude[/B]
11.027847         77.007263
11.027687         77.006943
11.025792         77.006935
Member Avatar for diafol

Can't you add and remove points via the API? However, I don't think it will change in real time, otherwise you'd have to Ajax the DB/ Map container every 30s or so.

My take:
If you can store the data automatically.
On page load, get the latest DB lat/long and then load the map with only the latest point and the route.
Is that what you want/need. Can you do it?

If you're using V.3:

var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
  var myOptions = {
    zoom: 4,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
  var marker = new google.maps.Marker({
      position: myLatlng, 
      map: map, 
      title:"Hello World!"
  });

from the API documentation.

Can't you add and remove points via the API? However, I don't think it will change in real time, otherwise you'd have to Ajax the DB/ Map container every 30s or so.

My take:
If you can store the data automatically.
On page load, get the latest DB lat/long and then load the map with only the latest point and the route.
Is that what you want/need. Can you do it?

If you're using V.3:

var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
  var myOptions = {
    zoom: 4,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
  var marker = new google.maps.Marker({
      position: myLatlng, 
      map: map, 
      title:"Hello World!"
  });

from the API documentation.

Thanks for your effort Ardav. I'll try this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.