Good evening! I am developing a web page where the user can draw a route. I use google maps api. I need to get the latitude and longitude pairs from the route, load to a C # object and, after working latitude and longitude information, return the lat. and long. for google maps to color the route according to the information that I will return. For example: when I return latitude: -12.123, longitude: 13.123 I need it to be colored according to a weight I'm going to pass. For example, if the weight is less than 5, there it colors yellow, greater than five, in blue. I'll post my code that generates the route for who knows you will help me.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script><scriptlanguage="javascript" type="text/javascript">
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
function InitializeMap() {
directionsDisplay = new google.maps.DirectionsRenderer();
var latlng = new google.maps.LatLng(-19.9412735, -44.07623219999999);
var myOptions =
{
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('directionpanel'));
var control = document.getElementById('control');
control.style.display = 'block';
}
function calcRoute() {
var start = document.getElementById('startvalue').value;
var end = document.getElementById('endvalue').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 Button1_onclick() {
calcRoute();
}
window.onload = InitializeMap;
</script>