Created
May 9, 2014 16:10
Star
You must be signed in to star a gist
javascript_route_data_full.js
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 originStop = new MRouteStop(); | |
originStop.description = "Avenida Paulista, 1000 - São Paulo / SP"; | |
originStop.point = new MPoint(-46.6520066, -23.5650127); | |
var destinationStop = new MRouteStop(); | |
destinationStop.description = "Av Pres Juscelino Kubitschek, 1000 - São Paulo / SP"; | |
destinationStop.point = new MPoint(-46.679055, -23.589735); | |
var routeStops = new Array; | |
var routePointAux; | |
routePointAux = new MRoutePoint(); | |
routePointAux.routeStop = originStop; | |
routeStops.push(routePointAux); | |
routePointAux = new MRoutePoint(); | |
routePointAux.routeStop = destinationStop; | |
routeStops.push(routePointAux); | |
var routeOptions = new MRouteOptions(); | |
var routeDetails = new MRouteDetails(); | |
routeDetails.optimizeRoute = true; | |
routeDetails.descriptionType = 0; | |
routeDetails.routeType = 1; | |
var vehicle = new MVehicle(); | |
vehicle.tankCapacity = 20; | |
vehicle.averageConsumption = 9; | |
vehicle.fuelPrice = 3; | |
vehicle.averageSpeed = 60; | |
vehicle.tollFeeCat = 2; | |
routeOptions.language = "portugues"; | |
routeOptions.routeDetails = routeDetails; | |
routeOptions.vehicle = vehicle; | |
var callback = { | |
onSuccess: function (response) { | |
function getRouteTotals(routeTotalsResponse) { | |
var routeTotals = "[RouteTotals]"; | |
routeTotals += "<br/>"; | |
routeTotals += "totalDistance: " + routeTotalsResponse.totalDistance; | |
routeTotals += ", totalTime: " + routeTotalsResponse.totalTime; | |
routeTotals += ", totalFuelUsed: " + routeTotalsResponse.totalFuelUsed; | |
routeTotals += ", totaltollFeeCost: " + routeTotalsResponse.totaltollFeeCost; | |
routeTotals += ", totalFuelUsed: " + routeTotalsResponse.totalFuelUsed; | |
routeTotals += ", totalCost: " + routeTotalsResponse.totalCost; | |
routeTotals += ", taxiFare1: " + routeTotalsResponse.taxiFare1; | |
routeTotals += ", taxiFare2: " + routeTotalsResponse.taxiFare2; | |
routeTotals += "<br/><br/>"; | |
return routeTotals; | |
} | |
function getMapInfo(mapInfoResponse) { | |
var mapInfo = "[MapInfo]"; | |
mapInfo += "<br/>"; | |
mapInfo += "url: " + mapInfoResponse.url; | |
mapInfo += ", extent - xMax: " + mapInfoResponse.extent.XMax; | |
mapInfo += ", extent - yMax: " + mapInfoResponse.extent.YMax; | |
mapInfo += ", extent - xMin: " + mapInfoResponse.extent.XMin; | |
mapInfo += ", extent - yMin: " + mapInfoResponse.extent.YMin; | |
mapInfo += "<br/><br/>"; | |
return mapInfo; | |
} | |
function getSegDescription(segDescriptionResponse) { | |
var segDescription = "[SegmentDescription]"; | |
for (var i = 0; i < segDescriptionResponse.length; i++) { | |
segDescription += "<br/>"; | |
segDescription += "city - name: " + segDescriptionResponse[i].city.name; | |
segDescription += ", city - state: " + segDescriptionResponse[i].city.state; | |
segDescription += ", command: " + segDescriptionResponse[i].command; | |
segDescription += ", cumulativeDistance: " + segDescriptionResponse[i].cumulativeDistance; | |
segDescription += ", description: " + segDescriptionResponse[i].description; | |
segDescription += ", distance: " + segDescriptionResponse[i].distance; | |
segDescription += ", poiRoute: " + segDescriptionResponse[i].poiRoute; | |
segDescription += ", poiRouteDetails: " + segDescriptionResponse[i].poiRouteDetails; | |
segDescription += ", point - x: " + segDescriptionResponse[i].point.x; | |
segDescription += ", point - y: " + segDescriptionResponse[i].point.y; | |
segDescription += ", roadType: " + segDescriptionResponse[i].roadType; | |
segDescription += ", tollFee: " + segDescriptionResponse[i].tollFee; | |
segDescription += ", tollFeeDetails - name: " + segDescriptionResponse[i].tollFeeDetails.name; | |
segDescription += ", tollFeeDetails - direction: " + segDescriptionResponse[i].tollFeeDetails.direction; | |
segDescription += ", tollFeeDetails - address: " + segDescriptionResponse[i].tollFeeDetails.address; | |
segDescription += ", tollFeeDetails - concession: " + segDescriptionResponse[i].tollFeeDetails.concession; | |
segDescription += ", tollFeeDetails - phone: " + segDescriptionResponse[i].tollFeeDetails.phone; | |
segDescription += "<br/>"; | |
} | |
segDescription += "<br/>"; | |
return segDescription; | |
} | |
function getRouteSummary(routeSummaryResponse) { | |
var routeSummary = "[RouteSummary]"; | |
for (var i = 0; i < routeSummaryResponse.length; i++) { | |
routeSummary += "<br/>"; | |
routeSummary += "description: " + routeSummaryResponse[i].description; | |
routeSummary += ", distance: " + routeSummaryResponse[i].distance; | |
routeSummary += ", point - x: " + routeSummaryResponse[i].point.x; | |
routeSummary += ", point - y: " + routeSummaryResponse[i].point.y; | |
} | |
routeSummary += "<br/><br/>"; | |
return routeSummary; | |
} | |
var responseData = ""; | |
responseData += getMapInfo(response.MapInfo); | |
responseData += getSegDescription(response.segDescription); | |
responseData += getRouteTotals(response.routeTotals); | |
responseData += getRouteSummary(response.routeSummary); | |
document.getElementById("divInfo").innerHTML = responseData; | |
}, | |
onError: function (errorMessage) { | |
document.getElementById("divInfo").innerHTML = "error message: " + errorMessage; | |
} | |
} | |
var routeManager = new MRouteMannager(map); | |
routeManager.createRoute(routeStops, routeOptions, null, callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment