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
var divIdName = "divMap"; | |
var map = new MMap2(divIdName); | |
var point = new MPoint(-46.6520066, -23.5650127); | |
var zoomLevel = 8; | |
map.setCenter(point, zoomLevel); | |
var getRouteStops = function () { | |
var getOriginStop = function () { | |
var originStop = new MRouteStop(); | |
originStop.description = "Avenida Paulista, 1000 - São Paulo / SP"; | |
originStop.point = new MPoint(-46.6520066, -23.5650127); | |
return originStop; | |
}; | |
var getDestinationStop = function () { | |
var destinationStop = new MRouteStop(); | |
destinationStop.description = "Av Pres Juscelino Kubitschek, 1000 - São Paulo / SP"; | |
destinationStop.point = new MPoint(-46.679055, -23.589735); | |
return destinationStop; | |
}; | |
var routeStops = new Array; | |
var routePointAux; | |
routePointAux = new MRoutePoint(); | |
routePointAux.routeStop = getOriginStop(); | |
routeStops.push(routePointAux); | |
routePointAux = new MRoutePoint(); | |
routePointAux.routeStop = getDestinationStop(); | |
routeStops.push(routePointAux); | |
return routeStops; | |
}; | |
var getRouteOptions = function () { | |
var getRouteDetails = function () { | |
var routeDetails = new MRouteDetails(); | |
routeDetails.optimizeRoute = true; | |
routeDetails.descriptionType = 0; | |
routeDetails.routeType = 21; | |
return routeDetails; | |
}; | |
var getVehicle = function () { | |
var vehicle = new MVehicle(); | |
vehicle.tankCapacity = 20; | |
vehicle.averageConsumption = 9; | |
vehicle.fuelPrice = 3; | |
vehicle.averageSpeed = 60; | |
vehicle.tollFeeCat = 2; | |
return vehicle; | |
}; | |
var routeOptions = new MRouteOptions(); | |
routeOptions.language = "portugues"; | |
routeOptions.routeDetails = getRouteDetails(); | |
routeOptions.vehicle = getVehicle(); | |
return routeOptions; | |
}; | |
var routeStops = getRouteStops(); | |
var routeOptions = getRouteOptions(); | |
var routeManager = new MRouteMannager(map); | |
routeManager.createRoute(routeStops, routeOptions, null, function (response) { | |
var getPublicTransportationDetails = function (segmentDescription) { | |
var getFromSegmentDescription = function (segmentDescription) { | |
for (var index = 0; index < segmentDescription.length; index++) { | |
if (segmentDescription[index].publicTransportationDetails != null) | |
return segmentDescription[index].publicTransportationDetails; | |
} | |
}; | |
var responseFormatter = function (publicTransportationDetails) { | |
var response = ""; | |
for (var index = 0; index < publicTransportationDetails.length; index++) { | |
response += "Description: " + publicTransportationDetails[index].description; | |
response += ", Details: " + publicTransportationDetails[index].details; | |
response += ", Direction: " + publicTransportationDetails[index].direction; | |
response += ", Distance: " + publicTransportationDetails[index].distance; | |
response += ", Line: " + publicTransportationDetails[index].line; | |
response += ", Point = Latitude: " + publicTransportationDetails[index].point.y; | |
response += ", Longitude: " + publicTransportationDetails[index].point.x; | |
response += ", Type: " + publicTransportationDetails[index].type; | |
response += "<br/><br/>"; | |
} | |
return response; | |
}; | |
var publicTransportationDetails = getFromSegmentDescription(segmentDescription); | |
var response = responseFormatter(publicTransportationDetails); | |
return response; | |
}; | |
var publicTransportationDetails = getPublicTransportationDetails(response.segDescription); | |
document.getElementById("divInfo").innerHTML = publicTransportationDetails; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment