無題

文章推薦指數: 80 %
投票人數:10人

setMap(map); // point the directions to the container for the direction details ... display the direction details in the container directionsDisplay. vardirectionDisplay,map; vardirectionsService=newgoogle.maps.DirectionsService(); vargeocoder=newgoogle.maps.Geocoder(); functioninitialize(){ //setthedefaultcenterofthemap varlatlng=newgoogle.maps.LatLng(-25.166802,29.082124); varlatlng1=newgoogle.maps.LatLng(-25.166802,29.082124); //setrouteoptions(draggablemeansyoucanalter/dragtherouteinthemap) varrendererOptions={draggable:true}; directionsDisplay=newgoogle.maps.DirectionsRenderer(rendererOptions); //setthedisplayoptionsforthemap varmyOptions={ zoom:14 , center:latlng, mapTypeId:google.maps.MapTypeId.ROADMAP, mapTypeControl:false, styles:[{"stylers":[{"saturation":-100},{"gamma":1}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]},{"featureType":"poi.business","elementType":"labels.text","stylers":[{"visibility":"off"}]},{"featureType":"poi.business","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"poi.place_of_worship","elementType":"labels.text","stylers":[{"visibility":"off"}]},{"featureType":"poi.place_of_worship","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"geometry","stylers":[{"visibility":"simplified"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"saturation":50},{"gamma":0},{"hue":"#50a5d1"}]},{"featureType":"administrative.neighborhood","elementType":"labels.text.fill","stylers":[{"color":"#333333"}]},{"featureType":"road.local","elementType":"labels.text","stylers":[{"weight":0.5},{"color":"#333333"}]},{"featureType":"transit.station","elementType":"labels.icon","stylers":[{"gamma":1},{"saturation":50}]}] , scrollwheel:false }; map=newgoogle.maps.Map(document.getElementById("map_canvas"),myOptions); varcontentString1=''+ ''+ ''+ 'MaatsebeCountryLodge'+ ''+ ''+ '  R573MolotoRoad,NexttoMoutsiyaMall'+'  0736808051'+'  [email protected]'+'  ViewinGoogleMaps'+''+ ''; varinfowindow1=newgoogle.maps.InfoWindow({ content:contentString1 }); varcustomMarker1=newgoogle.maps.Marker({ position:latlng1, map:map, title:"MaatsebeCountryLodge", icon:{ path:fontawesome.markers.MAP_MARKER, scale:1.3, strokeWeight:0.6, strokeColor:'#000', strokeOpacity:1, fillColor:'#753e08', fillOpacity:1, anchor:newgoogle.maps.Point(20,0), } }); customMarker1.addListener('click',function(){ infowindow1.open(map,customMarker1); }); //bindthemaptothedirections directionsDisplay.setMap(map); //pointthedirectionstothecontainerforthedirectiondetails directionsDisplay.setPanel(document.getElementById("directionsPanel")); } functioncalcRoute(){ //getthetravelmode,startpointandviapointfromtheform vartravelMode=$('input[name="travelMode"]:checked').val(); varstart=$("#routeStart").val(); varend=$("#routeEnd").val(); //composeaarraywithoptionsforthedirections/routerequest varrequest={ origin:start, destination:end, unitSystem:google.maps.UnitSystem.METRIC, travelMode:google.maps.DirectionsTravelMode[travelMode] }; //callthedirectionsAPI directionsService.route(request,function(response,status){ if(status==google.maps.DirectionsStatus.OK){ //directionsreturnedbytheAPI,clearthedirectionspanelbeforeaddingnewdirections $('#directionsPanel').empty(); //displaythedirectiondetailsinthecontainer directionsDisplay.setDirections(response); }else{ //alertanerrormessagewhentheroutecouldnogbecalculated. if(status=='ZERO_RESULTS'){ alertify.alert('Noroutecouldbefoundbetweentheoriginanddestination.'); }elseif(status=='UNKNOWN_ERROR'){ alertify.alert('Adirectionsrequestcouldnotbeprocessedduetoaservererror.Therequestmaysucceedifyoutryagain.'); }elseif(status=='REQUEST_DENIED'){ alertify.alert('Thiswebpageisnotallowedtousethedirectionsservice.'); }elseif(status=='OVER_QUERY_LIMIT'){ alertify.alert('Thewebpagehasgoneovertherequestslimitintooshortaperiodoftime.'); }elseif(status=='NOT_FOUND'){ alertify.alert('Atleastoneoftheorigin,destination,orwaypointscouldnotbegeocoded.'); }elseif(status=='INVALID_REQUEST'){ alertify.alert('TheDirectionsRequestprovidedwasinvalid.'); }else{ alertify.alert("Therewasanunknownerrorinyourrequest.Requeststatus:nn"+status); } } }); } google.maps.event.addDomListener(window,'load',initialize);



請為這篇文章評分?