Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.