Created
May 25, 2013 04:50
-
-
Save preddy5/5647950 to your computer and use it in GitHub Desktop.
My code(header files) for NAVATA transport Vijayawada to display their branches details on a map.
Technologies used:
Javascript,
JQuery,
Google maps API v3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" | |
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAMz7uQyLc60w7xoUC50zHeL-6uS7y5RBA&sensor=false"> | |
</script> | |
<script language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> | |
<script> | |
var directionsDisplay; | |
var directionsService = new google.maps.DirectionsService(); | |
var map; | |
google.maps.visualRefresh = true; | |
function initialize() { | |
directionsDisplay = new google.maps.DirectionsRenderer(); | |
var mapOptions = { | |
zoom:6, | |
mapTypeId: google.maps.MapTypeId.ROADMAP, | |
center: new google.maps.LatLng(20,77) | |
} | |
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); | |
directionsDisplay.setMap(map); | |
google.maps.event.addListener(map,'click',function(event){ | |
placeMarker(event.latLng) | |
}); | |
} | |
function placeMarker(location, message){ | |
var image = new google.maps.MarkerImage( | |
'http://maps.google.com/mapfiles/ms/micons/blue-dot.png', | |
new google.maps.Size(32, 32), // size | |
new google.maps.Point(0,0), // origin | |
new google.maps.Point(16, 32) // anchor | |
); | |
var behind = new google.maps.MarkerImage( | |
'http://maps.google.com/mapfiles/ms/micons/msmarker.shadow.png', | |
new google.maps.Size(59, 32), // size | |
new google.maps.Point(0,0), // origin | |
new google.maps.Point(16, 32) // anchor | |
); | |
var marker = new google.maps.Marker({ | |
position: location, | |
map: map, | |
icon: image, | |
shadow:behind | |
}); | |
showinfo(message,location,marker); | |
} | |
function calcRoute(start,end) { | |
//var start = document.getElementById('start').value; | |
//var end = document.getElementById('end').value; | |
var request = { | |
origin:start, | |
destination:end, | |
travelMode: google.maps.DirectionsTravelMode.DRIVING | |
}; | |
directionsService.route(request, function(response, status) { | |
if (status == google.maps.DirectionsStatus.OK) { | |
directionsDisplay.setDirections(response); | |
} | |
}); | |
} | |
function showinfo(message, position,marker){ | |
var infowindow = new google.maps.InfoWindow({ | |
content: message, | |
size: new google.maps.Size(50,50), | |
position: position | |
}); | |
infowindow.open(map,marker); | |
} | |
google.maps.event.addDomListener(window, 'load', initialize); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment