Jump to content

Google Map Get distance issues


marksie1988

Recommended Posts

Hi Guys,

 

i have got a script that gets directions from point a to point b etc, i need to also output the distance of the journey which will populate a div further down the page below is my code but i dont know why i cant get the distance to show in the div.

 


function initialize() {
if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("svmap_canvas"),{mapTypes:[G_NORMAL_MAP]});
	gdir = new GDirections(map, document.getElementById("svmap_directions"));
	var mapControl = new GMapTypeControl();
	map.addControl(mapControl);map.addControl(new GSmallMapControl());map.enableDoubleClickZoom();map.enableScrollWheelZoom();var geocoder = new GClientGeocoder();
	var myIcon = new GIcon();
	myIcon.image = "http://labs.google.com/ridefinder/images/mm_20_orange.png";
	myIcon.iconAnchor = new GPoint((markerImage1.width/2),markerImage1.height);
	markerOptions = { icon:myIcon, draggable: false, "title":"Drax Solutions LLP" };
	var point1 = new GLatLng(53.7726417, -1.7056978);
	map.setCenter(point1, 10);
	var marker1 = new GMarker(point1, markerOptions);
	map.addOverlay(marker1);
	var distance = gdir.getDistance();
	document.getElementById("roundmiles").innerHTML = distance;


}
}

 

Link to comment
https://forums.phpfreaks.com/topic/226459-google-map-get-distance-issues/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.