[Google Maps API v2] Conversion from V2 to v3 getting script error in http://maps.gstatic.com/intl/en_us/mapfiles/api-3/12/9/main.js
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&key=<%=strGk%>"></script> <script type="text/javascript"> var map; var gdir; var geocoder = null; var addressMarker; var directionsDisplay; var directionsService = new google.maps.DirectionsService(); var startAddress; var endAddress; function initialize() { var myOptions = { zoom: 7, mapTypeId: google.maps.MapTypeId.ROADMAP, center: "<%=strOrig%>", mapTypeControl: true, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR, position: google.maps.ControlPosition.BOTTOM }, navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.ZOOM_PAN, position: google.maps.ControlPosition.TOP_RIGHT }, scaleControl: true, scaleControlOptions: { position: google.maps.ControlPosition.TOP_LEFT } } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); alert("a") // gdir = new GDirections(map, document.getElementById("directions")); // gdir = new DirectionService(map, document.getElementById("directions")); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById("directions")); google.maps.event.addListener(directionsDisplay, "addoverlay", afterDir); //GEvent.addListener(gdir, "addoverlay", afterDir); // google.maps.event.addListener(gdir, "addoverlay", afterDir); //GEvent.addListener(gdir, "error", handleErrors); google.maps.event.addListener(directionsDisplay, "error", handleErrors); // geocoder = new GClientGeocoder(); geocoder = new google.maps.Geocoder(); if (geocoder) { geocoder.getLatLng( "<%=strOrig%>", function (point) { if (!point) { alert("<%=strOrig%>" + " not found"); } else { // alert("<%=strOrig%>") var OrigLat = point.lat().toFixed(5); var OrigLng = point.lng().toFixed(5); // alert(OrigLat) // alert(OrigLng) if ((OrigLat < 26.3170) || (OrigLat > 26.9892) || (OrigLng < -80.8975) || (OrigLng > -80.0177)) { alert("Origin is not PBC address") parent.window.returnValue = "0"; needToConfirm = false; var f = document.getElementById('frmPage'); window.self.close(); } } }); } if (geocoder) { geocoder.getLatLng( "<%=strDest%>", function (point) { if (!point) { alert("<%=strDest%>" + " not found"); } else { // alert("<%=strDest%>") var DestLat = point.lat().toFixed(5); var DestLng = point.lng().toFixed(5); // alert(DestLat) // alert(DestLng) if ((DestLat < 26.3170) || (DestLat > 26.9892) || (DestLng < -80.8975) || (DestLng > -80.0177)) { alert("Destination is not PBC address") parent.window.returnValue = "0"; needToConfirm = false; var f = document.getElementById('frmPage'); window.self.close(); } } }); } setDirections("<%=strOrig%>", "<%=strDest%>", "en_US"); calcRoute("<%=strOrig%>", "<%=strDest%>"); } //} function afterDir() { lstrDistance = gdir.getDistance(); document.getElementById("distance_road").innerHTML = lstrDistance.html; } function calcRoute(location1, location2) { var directionsService = new google.maps.DirectionsService(); var directionsDisplay = new google.maps.DirectionsRenderer(); var start = location1; var end = location2; var f = document.forms[0]; var request = { origin: start, destination: end, waypoints: [{ location: start }, { location: end}], travelMode: google.maps.DirectionsTravelMode.DRIVING, optimizeWaypoints: false }; directionsService.route(request, function (response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); var route = response.routes[0]; startAddress = route.legs[1].start_address; endAddress = route.legs[1].end_address; } }); } function setDirections(fromAddress, toAddress, locale) { var opts = {}; var f = document.forms[0]; var opts1 = {}; gdir.load("from: " + fromAddress + " to: " + toAddress, opts); } function callroute() { document.frmPage.submit(); } function handleErrors() { if (gdir.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.getStatus().code); alert("Please enter correct Origin/Destination location"); parent.window.returnValue = "0"; window.close(); } else if (gdir.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.getStatus().code); alert("Please enter correct Origin/Destination location"); parent.window.returnValue = "0"; window.close(); } else if (gdir.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.getStatus().code); alert("Please enter correct Origin/Destination location"); parent.window.returnValue = "0"; window.close(); } // else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong // alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code); else if (gdir.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.getStatus().code); alert("Please enter correct Origin/Destination location"); parent.window.returnValue = "0"; window.close(); } else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) {//alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code); alert("Please enter correct Origin/Destination location"); parent.window.returnValue = "0"; window.close(); } else { alert("An unknown error occurred."); alert("Please enter correct Origin/Destination location"); parent.window.returnValue = "0"; window.close(); } } function onGDirectionsLoad() { // Use this function to access information about the latest load() // results. // e.g. // document.getElementById("getStatus").innerHTML = gdir.getStatus().code; // and yada yada yada... } </script> | I am converting my code from version 2 to version 3. I am getting script error in http://maps.gstatic.com/intl/en_us/mapfiles/api-3/12/9/main.js My code on the page is as |
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 google-maps-api+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home