<script type="text/javascript"
src="//maps.googleapis.com/maps/api/js?key=AIzaSyANpAUROdUr6hlIM5vNyiCYsoacowmoNdU&sensor=false<?php
echo $languagev3; ?>"></script>
<script type="text/javascript">
var map = new Array();
var gdir = new Array();
var geocoder = null;
var addressMarker;
var mode;
var total = '';
var vCount = 0;
var vCountLength = 0;
function initialize(a, lat, long, driveMode,
fromTitle, toTitle, disp) {
//if (GBrowserIsCompatible()) { // v2
//map[a] = new
GMap2(document.getElementById("map_canvas_" + a)); //v2
//map[a] = new
google.maps.Map(document.getElementById("map_canvas_" + a)); //v3
map[a] = new
google.maps.Map(document.getElementById("map_canvas_" + a), {
mapTypeId:
google.maps.MapTypeId.ROADMAP
});
//gdir[a] = new GDirections(map[a],
document.getElementById("directions_" + a)); //v2
//gdir[a] = new
google.maps.DirectionsRenderer(map[a],
document.getElementById("directions_" + a)); //v3
var directionsService = new
google.maps.DirectionsService();
var directionsDisplay = new
google.maps.DirectionsRenderer();
directionsDisplay.setMap(map[a]);
directionsDisplay.setPanel(document.getElementById("directions_" + a));
//GEvent.addListener(gdir[a],
"addoverlay", function() { //v2
google.maps.event.addListener(directionsDisplay, "addoverlay", function()
{ //v3
var poly = gdir[a].getPolyline();
if (poly.getVertexCount() > 85) {
//document.getElementById("staticMapOverviewIMG_" + a).innerHTML = "Error:
This route has too many vertices.";
//return;
vCount = poly.getVertexCount();
vCountLength = Math.ceil(vCount
/ 75);
}
var baseUrl =
"http://maps.google.com/staticmap?";
var params = [];
var markersArray = [];
markersArray.push(poly.getVertex(0).toUrlValue(5) + ",greena");
markersArray.push(poly.getVertex(poly.getVertexCount()-1).toUrlValue(5) +
",greenb");
params.push("markers=" +
markersArray.join("|"));
var polyParams =
"rgba:0x0000FF80,weight:5|";
var polyLatLngs = [];
if(vCount > 0) {
for(var j = 0; j < vCount;
j+=vCountLength) {
polyLatLngs.push(poly.getVertex(j).lat().toFixed(5) + "," +
poly.getVertex(j).lng().toFixed(5));
}
vCount = 0;
vCountLength = 0;
} else {
for(var j = 0; j <
poly.getVertexCount(); j++) {
polyLatLngs.push(poly.getVertex(j).lat().toFixed(5) + "," +
poly.getVertex(j).lng().toFixed(5));
}
}
params.push("path=" + polyParams +
polyLatLngs.join("|"));
params.push("size=500x500");
//params.push("key=ABQIAAAAjU0EJWnWPMv7oQ-jjS7dYxSPW5CJgpdgO_s4yyMovOaVh_KvvhSfpvagV18eOyDWu7VytS6Bi1CWxw");
//params.push("key=AIzaSyCRbO_BNON-s1hyJJ0TxaZ5BHh6xwe7kUY");
//params.push("key=ABQIAAAAuaIJrO3VAESFZ8LtYwtRkBQ6OzCYB8ee921g3Hh3RoYelt_AFRTNGbUV4mJ9V2xwU7SHlQzsoL6-gQ");
// live
params.push("key=AIzaSyANpAUROdUr6hlIM5vNyiCYsoacowmoNdU"); // local
baseUrl += params.join("&");
var extraParams = [];
extraParams.push("center=" +
map[a].getCenter().lat().toFixed(6) + "," +
map[a].getCenter().lng().toFixed(6));
extraParams.push("zoom=" +
map[a].getZoom());
baseUrl += "&" +
extraParams.join("&");
addImg(baseUrl,
"staticMapOverviewIMG_" + a, a);
var ale = gdir[a].getRoute(0);
makeDirections(ale, a, fromTitle,
toTitle, disp, map[a].getZoom());
});
//GEvent.addListener(gdir[a], "error",
function() { //v2
google.maps.event.addListener(directionsDisplay, "error", function() {
//v3
if (gdir[a].getStatus().code ==
G_GEO_UNKNOWN_ADDRESS) {
alert("No corresponding
geographic location could be found for one of the specified addresses. This
may be due to the fact that the address is relatively new, or it may be
incorrect.\nError code: " + gdir[a].getStatus().code);
} else if (gdir[a].getStatus().code
== G_GEO_SERVER_ERROR) {
alert("A geocoding or
directions request could not be successfully processed, yet the exact
reason for the failure is not known.\n Error code: " +
gdir[a].getStatus().code);
} else if (gdir[a].getStatus().code
== G_GEO_MISSING_QUERY) {
alert("The HTTP q parameter was
either missing or had no value. For geocoder requests, this means that an
empty address was specified as input. For directions requests, this means
that no query was specified in the input.\n Error code: " +
gdir[a].getStatus().code);
} else if (gdir[a].getStatus().code
== G_GEO_BAD_KEY) {
alert("The given key is either
invalid or does not match the domain for which it was given. \n Error code:
" + gdir[a].getStatus().code);
} else if (gdir[a].getStatus().code
== G_GEO_BAD_REQUEST) {
alert("A directions request
could not be successfully parsed.\n Error code: " +
gdir[a].getStatus().code);
} else if (gdir[a].getStatus().code
== G_GEO_UNKNOWN_DIRECTIONS) {
alert("The GDirections object
could not compute directions between the points mentioned in the query.
This is usually because there is no route available between the two points,
or because we do not have data for routing in that region.\n Error code: "
+ gdir[a].getStatus().code);
} else {
alert("An unknown error
occurred.");
}
});
//gdir[a].load("from:" + lat + " to: "
+ long, {travelMode:driveMode<?php echo $locale; ?>});
var request = {
origin: lat,
destination: long,
travelMode:
google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request,
function(response, status) {
if (status ==
google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
//} // v2
}
function addImg(url, id, ct) {
//TODO The Google Maps API sets max. URL
length as 2048 bytes. Any requests longer than this give HTTP Error : 414
(Request-URI Too Large)
//if(document.all) { // change by
vallabh on 09MAY2013 for IE 9 and IE 10 issue
if(document.all &&
(navigator.userAgent.search('MSIE 7.0') != -1 ||
navigator.userAgent.search('MSIE 8.0') != -1)){
// DOM Element creation in IE
var img = document.createElement('<img
src="' + url + '">');
var input1 =
document.createElement('<input type="hidden" id="img_' + ct + '"
name="img_' + ct + '" value="' + url + '" />');
} else {
var img =
document.createElement("img");
img.setAttribute('src', url);
var input1 =
document.createElement('input');
input1.setAttribute('type', 'hidden');
input1.setAttribute('id', 'img_' + ct);
input1.setAttribute('name', 'img_' +
ct);
input1.setAttribute('value', url);
}
document.getElementById(id).innerHTML = "";
document.getElementById(id).appendChild(img);
document.adminForm.appendChild(input1);
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.