i'm trying to use gmap3 to do the above but am running into difficulty. i can get 'map' to display and stick a marker on it. i'm still getting to grips with javascript and i'm sure some of my syntax is off which obviously doesn't help.
am i on the right track with regards to using geolocation to get the user's location and then plot the route to a predefined location?
apologies for incorrect syntax - i'm finding it hard to keep track brackets when using JS.
i'm using the example which can be found here: http://gmap3.net/api/add-directions-renderer.html
<script type="text/javascript">
$(function () {
//get the user's location
function getLocation(){
$('#map').gmap3({
action : 'geoLatLng',
callback : function(latLng){
if (latLng){
$(this).gmap3({
action: 'addMarker',
latLng:latLng
},
"autofit");
}
}
});
}
//plot directions
function plotRoute() {
$('#map').gmap3({
action: 'getRoute',
options:{
origin: 'latLang',
destination: 'Tallaght Business Park, Dublin, Ireland'
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
callback: function(results){
if (!results) return;
$(this).gmap3({
action: 'init',
zoom: 13,
mapTyprId: google.maps.MapTypeId.ROADMAP,
streetViewControl: true
},
action: 'addDirectionsRenderer',
options: {
preserveViewPort: true,
draggable: true,
directions: results
}
);
}
});
}
});
</script>
to be placed in this div
<div class="gmap3" id="map"></div>