marksie1988 Posted February 2, 2011 Share Posted February 2, 2011 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/226459-google-map-get-distance-issues/ Share on other sites More sharing options...
sunfighter Posted February 3, 2011 Share Posted February 3, 2011 Should work if roundmiles is the id of the div and your not writing over it. put die; in your function and see. Quote Link to comment https://forums.phpfreaks.com/topic/226459-google-map-get-distance-issues/#findComment-1169254 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.