1//map functions for Google Maps API V3 by Ben Beckford 2 3/*Generate map styles at: http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html 4 5Example usage: 6 7<script type="text/javascript" src="scripts/jquery.js"></script> 8<script type="text/javascript" src="scripts/maps_functions_v3.js"></script> 9<script type="text/javascript" src="http://maps.google.co.uk/maps/api/js?sensor=false&key=ABQIAAAAQmgxb2K8HFvl_SKRZsLfwRSJx3J6llU8viU-jAWyZd7L5UlWBhRjtI42uk8PU0rAR9wp-UWRpqQSYQ"></script> 10 11<script type="text/javascript"> 12$(document).ready(function(){ 13 createMap({xmlPath: "storage/xml/locations.xml", 14 containerID: "map", 15 mouseWheel: true, 16 zoom: 12, 17 forceCenterLng: 51.5055, 18 forceCenterLat: -0.0738, 19 allControlsOn: false, 20 navigationControl: true, 21 mapTypeControl: true, 22 scaleControl: true, 23 fullscreenControl: false, 24 streetViewControl: true, 25 mapStyle: [ { featureType: "all", elementType: "all", stylers: [ { hue: "#ff0044" } ] } ] 26 }); 27 28}); 29</script> 30 31<div style="width: 650px; height: 600px" id="map"></div> 32 33*/ 34 35var Map, GMap, $Container, directionsService, directionsDisplay, geocoder, latlngbounds, markersArray, locationArray; 36var allControlsOn = false; 37var gmStartID = 0; 38 39var locationMarker, geocodeTimeout; 40var markerImage = "https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|4FB8F1|06418B"; 41var cp_mapZoom = 9; 42var geocodeComplete = true; 43 44 45function locationObject(){ 46 this.long = 0; 47 this.lat = 0; 48 this.title = ""; 49 this.address = ""; 50 this.link = ""; 51} 52 53function createMap(params) 54{ 55 56 if(params.pointArray != null) 57 { 58 setupMap(params); 59 } 60 else 61 { 62 params.pointArray = new Array(); 63 64 $.ajax({ 65 type: "GET", 66 url: encodeURI(params.xmlPath), 67 dataType: "xml", 68 success: function(xml) { 69 $(xml).find('xml').each(function(){ 70 71 72 $(this).find('location').each(function(){ 73 74 var long = $(this).attr("longitude"); 75 var lat = $(this).attr("latitude"); 76 var title = $(this).attr("title"); 77 var balloonContent = $(this).attr("balloonContent"); 78 79 var markerImage = ""; 80 81 if($(this).attr("icon") != null) 82 { 83 markerImage = $(this).attr("icon"); 84 } 85 86 params.pointArray.push({long: long, lat: lat, title: title, balloonContent: balloonContent, markerImage: markerImage}); 87 88 }); 89 90 }); 91 92 setupMap(params); 93 94 } 95 }); 96 } 97 98} 99 100var setupMap = function(params) { 101 102 google.maps.visualRefresh = true; 103 104 var markersArray = new Array(); 105 locationArray = new Array(); 106 var iconArray = new Array(); 107 108 var i = 0; 109 for(i = 0; i < params.pointArray.length; i++) 110 { 111 var location = new locationObject(); 112 location.long = params.pointArray[i].long; 113 location.lat = params.pointArray[i].lat; 114 location.title = params.pointArray[i].title; 115 if(location.title == null) 116 { 117 location.title = ""; 118 } 119 120 location.balloonContent = params.pointArray[i].balloonContent; 121 if(location.balloonContent == null) 122 { 123 location.balloonContent = ""; 124 } 125 126 locationArray.push(location); 127 128 var markerImage = ""; 129 130 if(params.pointArray[i].markerImage != null && params.pointArray[i].markerImage != "") 131 { 132 markerImage = params.pointArray[i].markerImage; 133 } 134 135 iconArray.push(markerImage); 136 } 137 138 geocoder = new google.maps.Geocoder(); 139 140 if(params.allControlsOn != null) 141 { 142 allControlsOn = params.allControlsOn; 143 } 144 145 var startPoint = new google.maps.LatLng(-0.1262295, 51.5001973); 146 147 var Options = { 148 center: startPoint, 149 zoom: 10, 150 mapTypeId: google.maps.MapTypeId.ROADMAP, 151 mapTypeControl: allControlsOn, 152 mapTypeControlOptions: {}, 153 scaleControl: allControlsOn, 154 fullscreenControl: allControlsOn, 155 disableDefaultUI: false, 156 scaleControlOptions: {}, 157 streetViewControl: allControlsOn, 158 streetViewControlOptions: {}, 159 overviewMapControl: allControlsOn, 160 overviewMapControlOptions: {}, 161 panControl: allControlsOn, 162 panControlOptions: {}, 163 zoomControl: allControlsOn, 164 zoomControlOptions: {}, 165 disableDoubleClickZoom: false 166 } 167 168 if(params.zoom != null) 169 { 170 Options.zoom = params.zoom; 171 } 172 if(params.mapTypeControl != null) 173 { 174 Options.mapTypeControl = params.mapTypeControl; 175 } 176 if(params.scaleControl != null) 177 { 178 Options.scaleControl = params.scaleControl; 179 } 180 if(params.fullscreenControl != null) 181 { 182 Options.fullscreenControl = params.fullscreenControl; 183 } 184 if(params.disableDefaultUI != null) 185 { 186 Options.disableDefaultUI = params.disableDefaultUI; 187 } 188 if(params.streetViewControl != null) 189 { 190 Options.streetViewControl = params.streetViewControl; 191 } 192 if(params.overviewMapControl != null) 193 { 194 Options.overviewMapControl = params.overviewMapControl; 195 } 196 if(params.navigationControl != null) 197 { 198 Options.panControl = params.navigationControl; 199 Options.zoomControl = params.navigationControl; 200 } 201 else 202 { 203 if(params.panControl != null) 204 { 205 Options.panControl = params.panControl; 206 } 207 if(params.zoomControl != null) 208 { 209 Options.zoomControl = params.zoomControl; 210 } 211 } 212 if(params.disableDoubleClickZoom != null) 213 { 214 Options.disableDoubleClickZoom = params.disableDoubleClickZoom; 215 } 216 217 if(params.mapStyle != null) 218 { 219 Options.mapTypeControlOptions = { mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'customMapStyle'] }; 220 } 221 else if(params.mapType != null) 222 { 223 switch(params.mapType) 224 { 225 case "satellite": 226 Options.mapTypeId = google.maps.MapTypeId.SATELLITE; 227 break; 228 case "hybrid": 229 Options.mapTypeId = google.maps.MapTypeId.HYBRID; 230 break; 231 case "terrain": 232 Options.mapTypeId = google.maps.MapTypeId.TERRAIN; 233 break; 234 } 235 } 236 237 if(params.mapTypeControlPosition != null) 238 { 239 Options.mapTypeControlOptions.position = getControlPosition(params.mapTypeControlPosition); 240 } 241 242 if(params.navigationControlPosition != null) 243 { 244 Options.navigationControlOptions.position = getControlPosition(params.navigationControlPosition); 245 } 246 247 if(params.scaleControlPosition != null) 248 { 249 Options.scaleControlOptions.position = getControlPosition(params.scaleControlPosition); 250 } 251 252 if(params.streetViewControlPosition != null) 253 { 254 Options.streetViewControlOptions.position = getControlPosition(params.streetViewControlPosition); 255 } 256 257 if(params.mouseWheel == false) 258 { 259 Options.scrollwheel = false; 260 } 261 262 if(params.$elm == null) 263 { 264 params.$elm = $('#'+params.containerID)[0]; 265 } 266 else if(params.$elm.length > 0) 267 { 268 params.$elm = params.$elm[0]; 269 } 270
271 if(params.touchControls === false && is_touch_device()) 272 { 273 Options.draggable = false; 274 275 params.$elm.addEventListener("touchstart", thisTouchStart, true); 276 params.$elm.addEventListener("touchend", thisTouchEnd, true); 277 params.$elm.addEventListener("touchmove", thisTouchMove, true); 278 } 279 280 GMap = new google.maps.Map(params.$elm, Options); 281 if (Map == null) { 282 Map = GMap; 283 } 284 var infowindow = new google.maps.InfoWindow(); 285 286 var start = 0, end = 0; 287 288 function thisTouchStart(e) 289 { 290 dragFlag = true; 291 start = e.touches[0].pageY; 292 } 293 294 function thisTouchEnd() 295 { 296 dragFlag = false; 297 } 298 299 function thisTouchMove(e) 300 { 301 if ( !dragFlag ) return; 302 end = e.touches[0].pageY; 303 window.scrollBy( 0,( start - end ) ); 304 } 305 306 function is_touch_device() { 307 return !!('ontouchstart' in window); 308 } 309 310 /* 311 if(params.markerImage != null) 312 { 313 var markerImage = params.markerImage; 314 315 if(params.markerCenterX != null && params.markerCenterY != null && params.markerWidth != null && params.markerHeight != null) 316 { 317 var imagePath = markerImage; 318 markerImage = new google.maps.MarkerImage( 319 imagePath, 320 // This marker width/height 321 new google.maps.Size(params.markerWidth, params.markerHeight), 322 // The marker top left origin (used for sprite images) 323 new google.maps.Point(0,0), 324 // The anchor for this image is the base of the flagpole at 0,32. 325 new google.maps.Point(params.markerCenterX, params.markerCenterY) 326 ); 327 328 } 329 330 addMarker(GMap, startPoint, markerImage, "", false); 331 } 332 */ 333 334 if(params.mapStyle != null) 335 { 336 var styledMapOptions = { 337 name: "customMapStyle" 338 } 339 340 var customMapType = new google.maps.StyledMapType(params.mapStyle, styledMapOptions); 341 342 GMap.mapTypes.set('customMapStyle', customMapType); 343 GMap.setMapTypeId('customMapStyle'); 344 } 345 346 latlngbounds = new google.maps.LatLngBounds(); 347 348 for (var i = 0; i < locationArray.length; i++) 349 { 350 var newPoint = new google.maps.LatLng(locationArray[i].long, locationArray[i].lat); 351 352 var marker = addMarker(GMap, {Point: newPoint, Icon: iconArray[i]}); 353 354 if(i == 0) 355 { 356 gmStartID = marker.__gm_id; 357 } 358 359 locationArray[i].gmid = marker.__gm_id; 360 marker.locationArrayId = i; 361 362 //var newTitle = locationArray[i].title; 363 // var newBalloonContent = locationArray[i].balloonContent; 364 365 if(locationArray[i].balloonContent != "") 366 { 367 google.maps.event.addListener(marker, 'click', function(e) { 368 //infowindow.setTitle(locationArray[this.__gm_id - gmStartID].title); 369 370 //infowindow.setContent(locationArray[this.__gm_id - gmStartID].balloonContent); 371 infowindow.setContent(locationArray[this.locationArrayId].balloonContent); 372 infowindow.open(GMap, this); 373 }); 374 } 375 376 markersArray.push(marker); 377 378 latlngbounds.extend(newPoint); 379 } 380 381 if(params.onStartOpenBubble != null) 382 { 383 google.maps.event.addListenerOnce(GMap, 'idle', function(){ 384 385 infowindow.setContent(locationArray[params.onStartOpenBubble-1].balloonContent); 386 infowindow.open(GMap, markersArray[params.onStartOpenBubble-1]); 387 }); 388 } 389 390 if(params.forceCenterLat != null && params.forceCenterLng != null) 391 { 392 var newPoint = new google.maps.LatLng(params.forceCenterLng, params.forceCenterLat); 393 GMap.setCenter( newPoint ); 394 } 395 else if(params.onStartOpenBubble == null) 396 { 397 if(params.zoom == null) 398 {
399 var sw = latlngbounds.getSouthWest(); 400 var ne = latlngbounds.getNorthEast(); 401 var GLOBE_WIDTH = 256; // a constant in Google's map projection 402 var west = sw.lng(); 403 var east = ne.lng(); 404 var angle = east - west; 405 if (angle < 0) { 406 angle += 360; 407 } 408 409 var newZoom = Math.round(Math.log(params.$elm.width() * 360 / angle / GLOBE_WIDTH) / Math.LN2) - 2; 410 411 GMap.setZoom( newZoom ); 412 } 413 GMap.setCenter( latlngbounds.getCenter() ); 414 } 415 416 417 418 if (typeof params.callbackFunc == 'function') { 419 params.callbackFunc(markersArray); 420 } 421 422 return(GMap); 423 424 425} 426 427var getControlPosition = function(positionString) { 428 429 switch(positionString) 430 { 431 case "TOP_CENTER": //indicates that the control should be placed along the top center of the map. 432 return(google.maps.ControlPosition.TOP_CENTER); 433 break; 434 case "TOP_LEFT": //indicates that the control should be placed along the top left of the map, with any sub-elements of the control "flowing" towards the top center 435 return(google.maps.ControlPosition.TOP_LEFT); 436 break; 437 case "TOP_RIGHT": //indicates that the control should be placed along the top right of the map, with any sub-elements of the control "flowing" towards the top center 438 return(google.maps.ControlPosition.TOP_RIGHT); 439 break; 440 case "LEFT_TOP": //indicates that the control should be placed along the top left of the map, but below any TOP_LEFT elements 441 return(google.maps.ControlPosition.LEFT_TOP); 442 break; 443 case "RIGHT_TOP": //indicates that the control should be placed along the top right of the map, but below any TOP_RIGHT elements 444 return(google.maps.ControlPosition.RIGHT_TOP); 445 break; 446 case "LEFT_CENTER": //indicates that the control should be placed along the left side of the map, centered between the TOP_LEFT and BOTTOM_LEFT positions 447 return(google.maps.ControlPosition.LEFT_CENTER); 448 break; 449 case "RIGHT_CENTER": //indicates that the control should be placed along the right side of the map, centered between the TOP_RIGHT and BOTTOM_RIGHT positions 450 return(google.maps.ControlPosition.RIGHT_CENTER); 451 break; 452 case "LEFT_BOTTOM": //indicates that the control should be placed along the bottom left of the map, but above any BOTTOM_LEFT elements 453 return(google.maps.ControlPosition.TOP_CENTER); 454 break; 455 case "RIGHT_BOTTOM": //indicates that the control should be placed along the bottom right of the map, but above any BOTTOM_RIGHT elements 456 return(google.maps.ControlPosition.TOP_CENTER); 457 break; 458 case "BOTTOM_CENTER": //indicates that the control should be placed along the bottom center of the map 459 return(google.maps.ControlPosition.BOTTOM_CENTER); 460 break; 461 case "BOTTOM_LEFT": //indicates that the control should be placed along the bottom left of the map, with any sub-elements of the control "flowing" towards the bottom center 462 return(google.maps.ControlPosition.BOTTOM_LEFT); 463 break; 464 case "BOTTOM_RIGHT": //indicates that the control should be placed along the bottom right of the map, with any sub-elements of the control "flowing" towards the bottom center 465 return(google.maps.ControlPosition.BOTTOM_RIGHT); 466 break; 467 default: 468 return(null); 469 break; 470 } 471} 472 473var getDistance = function(params) 474{ 475 var A = params.pointA; 476 var B = params.pointB; 477 478 directionsService = new google.maps.DirectionsService(); 479 480 var request = { 481 origin:A, 482 destination:B, 483 travelMode: google.maps.DirectionsTravelMode.DRIVING 484 }; 485 directionsService.route(request, function(response, status) { 486 if (status == google.maps.DirectionsStatus.OK) { 487 488 var distance = response.routes[0].legs[0].distance.value; 489 var timeSeconds = response.routes[0].legs[0].duration.value; 490 var timeFormatted = response.routes[0].legs[0].duration.text; 491 492 var distanceKilometres = parseFloat(distance / 1000); 493 var distanceMiles = format2Dec(distanceKilometres * 0.621371192); 494 distanceKilometres = format2Dec(distanceKilometres); 495 496 var returner = {distanceKilometres: distanceKilometres, distanceMiles: distanceMiles, timeSeconds: timeSeconds, timeFormatted: timeFormatted, pointA: A, pointB: B}; 497 params.callback(returner); 498 } 499 else 500 { 501 if(status == "ZERO_RESULTS") 502 { 503 params.callback(false); 504 } 505 } 506 }); 507} 508 509var removeMarker = function(marker) 510{ 511 if(marker != undefined) 512 { 513 marker.setMap(null); 514 } 515} 516 517var addMarker = function(MapObj, params) 518{ 519 if(params.CenterMap == null) 520 { 521 params.CenterMap = true; 522 } 523 524 var markerSettings = new Object; 525 markerSettings.map = MapObj; 526 markerSettings.position = params.Point; 527 528 if(params.Icon != null) 529 { 530 if(Modernizr.Detectizr.browser.name == "ie") 531 { 532 var image = { 533 url: params.Icon, 534 scaledSize: new google.maps.Size(50, 50) 535 } 536 } 537 else 538 { 539 var image = params.Icon 540 } 541 542 markerSettings.icon = image; 543 } 544 if(params.Title != null) 545 { 546 markerSettings.title = params.Title; 547 } 548 549 var newMarker = new google.maps.Marker(markerSettings); 550 551 if(params.InfoWindow != null && params.InfoWindow != "") 552 { 553 var infowindow = new google.maps.InfoWindow({ 554 content: params.InfoWindow 555 }); 556 557 google.maps.event.addListener(newMarker, 'click', function() { 558 infowindow.open(MapObj, newMarker); 559 }); 560 } 561 562 if(params.CenterMap == true) 563 { 564 MapObj.setCenter(params.Point); 565 } 566 567 return(newMarker); 568} 569 570var checkValidUKPoint = function(A, B) 571{ 572 var A = { 573 origin:location1, 574 destination: "6 Baker Street, Paddington, Greater London", 575 travelMode: google.maps.DirectionsTravelMode.DRIVING 576 }; 577 578 directionsService.route(request1, function(response, status) { 579 if(status == "ZERO_RESULTS") 580 { 581 //no route found 582 } 583 }); 584 585 var request2 = { 586 origin: B, 587 destination: "6 Baker Street, Paddington, Greater London", 588 travelMode: google.maps.DirectionsTravelMode.DRIVING 589 }; 590 591 directionsService.route(request2, function(response, status) { 592 if(status == "ZERO_RESULTS") 593 { 594 //no route found 595 } 596 }); 597} 598 599var format2Dec = function(num) 600{ 601 num *= 100; 602 num = parseInt(num); 603 num /= 100; 604 return num; 605} 606 607 608function codeAddress(address) { 609 geocoder.geocode( { 'address': address}, function(results, status) { 610 if (status == google.maps.GeocoderStatus.OK) { 611 alert(results[0].geometry.location); 612 } else { 613 alert("Geocode was not successful for the following reason: " + status); 614 } 615 }); 616} 617 618/*Map resize 619google.maps.event.trigger(startPointMap, 'resize'); 620*/ 621 622/*Zoom Map 623Map.setZoom(12); 624*/ 625 626/*Center Map 627Map.setCenter(point); 628*/ 629 630/*Directions 631 directionsService = new google.maps.DirectionsService(); 632 directionsDisplay = new google.maps.DirectionsRenderer(); 633*/ 634 635/*Draggable Marker 636 var newMarker = new google.maps.Marker({ 637 position: Point, 638 map: Map, 639 title: Title, 640 draggable: Draggable, 641 icon: "storage/images/maps_marker_a.png" 642 }); 643 644 google.maps.event.addListener(startMarker, 'dragend', function() { 645 newStartPoint = startMarker.getPosition(); 646 mapDragUpdate(); 647 }); 648*/ 649 650 651 652//Control Panel Location Functions: 653 654var initLocationGMap = function(geocodeCallback) { 655 656 var markerObj = function(long, lat, markerImage) { 657 this.long = long; 658 this.lat = lat; 659 this.markerImage = markerImage; 660 } 661 662 var zoom = cp_mapZoom; 663 var lat = 51.510; 664 var lng = -0.117; 665 666 if($('#locationLat').val() != "") 667 { 668 lat = $('#locationLat').val(); 669 lng = $('#locationLong').val(); 670 } 671 672 var markerArray = new Array(new markerObj(lat, lng, markerImage)); 673 674 setupMap({containerID: "rc_map_canvas", pointArray: markerArray, allControlsOn: true, mouseWheel: false, zoom: zoom, callbackFunc: function(markersArray) 675 { 676 locationMarker = markersArray[0]; 677 } 678 }); 679 680 $('#rcv_loc_name, #rcl_loc_name, #syu_loc_name, #rca_loc_name').keyup(function(e){
681 682 if(e.keyCode == 13) 683 { 684 clearTimeout(geocodeTimeout); 685 geocodeAddress(geocodeCallback); 686 } 687 else 688 { 689 clearTimeout(geocodeTimeout); 690 geocodeTimeout = setTimeout(function(){ geocodeAddress(geocodeCallback); }, 1000); 691 } 692 693 }).change(function(){ 694 geocodeAddress(geocodeCallback); 695 }); 696 697} 698 699var setupAddressInputMap = function($textInput, $latInput, $longInput, $mapWrapper, $countryCodeInput) 700{ 701 var markerObj = function(long, lat, markerImage) { 702 this.long = long; 703 this.lat = lat; 704 this.markerImage = markerImage; 705 } 706 707 var zoom = cp_mapZoom; 708 var lat = 51.510; 709 var lng = -0.117; 710 711 if($latInput.val() != "") 712 { 713 lat = $latInput.val(); 714 lng = $longInput.val(); 715 } 716 717 var markerArray = new Array(new markerObj(lat, lng, markerImage)); 718 719 location_autocomplete_init($textInput); 720 721 var theMarker = null; 722 723 var theMap = setupMap({$elm: $mapWrapper, pointArray: markerArray, allControlsOn: true, mouseWheel: false, zoom: zoom, callbackFunc: function(markersArray) 724 { 725 theMarker = markersArray[0]; 726 } 727 }); 728 729 $textInput.keyup(function(e){ 730 731 if(e.keyCode == 13) 732 { 733 clearTimeout(geocodeTimeout); 734 geocodeInputMapAddress($textInput, $latInput, $longInput, theMarker, theMap, $countryCodeInput); 735 } 736 else 737 { 738 clearTimeout(geocodeTimeout); 739 geocodeTimeout = setTimeout(function(){ geocodeInputMapAddress($textInput, $latInput, $longInput, theMarker, theMap, $countryCodeInput); }, 1000); 740 } 741 742 }).change(function(){ 743 geocodeInputMapAddress($textInput, $latInput, $longInput, theMarker, theMap, $countryCodeInput); 744 }); 745} 746 747var get_region_local_geocode_bias = function() { 748 if(typeof region_local_geocode_bias != "undefined") 749 { 750 return(region_local_geocode_bias); 751 } 752 else 753 { 754 return(""); 755 } 756} 757 758/* Check if string is a valid latitude and longitude */ 759function checkIfValidLatitudeAndLongitude(str) { 760 // Regular expression to check if string is a latitude and longitude 761 const regexExp = /^((\-?|\+?)?\d+(\.\d+)?),\s*((\-?|\+?)?\d+(\.\d+)?)$/gi; 762 763 return regexExp.test(str); 764} 765 766var geocodeInputMapAddress = function($textInput, $latInput, $longInput, marker, theMap, $countryCodeInput) { 767 clearTimeout(geocodeTimeout); 768 geocodeComplete = false; 769 770 var address = $textInput.val(); 771 var lat = 0; 772 var long = 0; 773 var useOriginalInput = false; 774 775 if(checkIfValidLatitudeAndLongitude(address)) { 776 // Getting required array form string 777 // by split and array.from methods 778 const separatedArray = Array.from( 779 address.split(',') 780 ); 781 782 lat = separatedArray[0]; 783 long = separatedArray[1]; 784 useOriginalInput = true; 785 } 786 787 geocoder.geocode( { 'address': address, 'region': get_region_local_geocode_bias()}, function(results, status) { 788 if (status == google.maps.GeocoderStatus.OK) { 789 790 theMap.setCenter(results[0].geometry.location); 791 theMap.setZoom(cp_mapZoom); 792 marker.setPosition(results[0].geometry.location); 793 794 if(useOriginalInput) { 795 $latInput.val(lat); 796 $longInput.val(long); 797 } else { 798 $latInput.val(results[0].geometry.location.lat()); 799 $longInput.val(results[0].geometry.location.lng()); 800 } 801 802 //strangely, not able to directly grab the country of a looked up address - have to look through the address components of the returned array and find component with a type 'country'. info here https://developers.google.com/maps/documentation/geocoding/intro 803 var countryCode = ''; 804 var address_components = results[0].address_components; 805 for(var i in address_components) 806 { 807 if(address_components[i]["types"].indexOf("country") != -1) 808 { 809 countryCode = address_components[i].short_name; 810 break; 811 } 812 } 813 $countryCodeInput.val(countryCode); 814 815 geocodeComplete = true; 816 if(typeof geocodeCallback == 'function') 817 { 818 geocodeCallback(); 819 } 820 } else { 821 geocodeComplete = true; 822 $latInput.val(""); 823 $longInput.val(""); 824 $countryCodeInput.val(""); 825 //alert('Geocode was not successful for the following reason: ' + status); 826 } 827 }); 828 829} 830 831var geocodeAddress = function(geocodeCallback) { 832 clearTimeout(geocodeTimeout); 833 geocodeComplete = false; 834 835 var address = ""; 836 837 if($('#rcv_loc_name').length > 0) 838 { 839 address = $('#rcv_loc_name').val(); 840 } 841 else if($('#rcl_loc_name').length > 0) 842 { 843 address = $('#rcl_loc_name').val(); 844 } 845 else if($('#syu_loc_name').length > 0) 846 { 847 address = $('#syu_loc_name').val(); 848 } 849 else if($('#rca_loc_name').length > 0) 850 { 851 address = $('#rca_loc_name').val(); 852 } 853 854 geocoder.geocode( { 'address': address}, function(results, status) { 855 if (status == google.maps.GeocoderStatus.OK) { 856 GMap.setCenter(results[0].geometry.location); 857 GMap.setZoom(cp_mapZoom); 858 locationMarker.setPosition(results[0].geometry.location); 859 $('#locationLat').val(results[0].geometry.location.lat()); 860 $('#locationLong').val(results[0].geometry.location.lng()); 861 geocodeComplete = true; 862 if(typeof geocodeCallback == 'function') 863 { 864 geocodeCallback(); 865 } 866 } else { 867 geocodeComplete = true; 868 $('#locationLat').val(""); 869 $('#locationLong').val(""); 870 //alert('Geocode was not successful for the following reason: ' + status); 871 } 872 }); 873 874}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.