" ]; function initialize() { /*// Create the autocomplete object, restricting the search // to geographical location types. pickup = new google.maps.places.Autocomplete( (document.getElementById('pickup_zip')), { }); dropoff = new google.maps.places.Autocomplete( (document.getElementById('drop_zip')), { }); // When the user selects an address from the dropdown, // populate the address fields in the form. google.maps.event.addListener(pickup, 'place_changed', function() { fillInAddress('pickup'); }); google.maps.event.addListener(dropoff, 'place_changed', function() { fillInAddress('dropoff'); }); */ // MAP var secheltLoc = new google.maps.LatLng(19.8852108,76.7905578); var myMapOptions = { zoom: 5 ,center: secheltLoc ,mapTypeId: google.maps.MapTypeId.ROADMAP ,scrollwheel: false }; var theMap = new google.maps.Map(document.getElementById("map_canvas"), myMapOptions); //var myIcon = new google.maps.MarkerImage(''); //var marker = new google.maps.Marker({ map: theMap, draggable: true, position: new google.maps.LatLng(26.8852108,75.7905578), //visible: true }); var marker1 = new google.maps.Marker({ map: theMap, draggable: true, position: new google.maps.LatLng(12.972916,77.594725), visible: true }); var boxText = document.createElement("div"); boxText.innerHTML = ""; var myOptions = { content: boxText ,disableAutoPan: false ,maxWidth: 0 ,pixelOffset: new google.maps.Size(-140, 0) ,zIndex: null ,closeBoxURL: "" ,infoBoxClearance: new google.maps.Size(1, 1) ,isHidden: false ,enableEventPropagation: false }; google.maps.event.addListener(marker, "click", function (e) { ib.open(theMap, this); }); google.maps.event.addListener(marker1, "click", function (e) { ib.open(theMap, this); }); /* var ib = new InfoBox(myOptions); ib.open(theMap, marker); */ } // [START region_fillform] function fillInAddress(action) { if(action == 'pickup') { // Get the place details from the autocomplete object. var place = pickup.getPlace(); // Get each component of the address from the place details for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if(addressType == 'locality') p_city = place.address_components[i]['long_name']; if(addressType == 'administrative_area_level_1') p_state = place.address_components[i]['long_name']; if(addressType == 'postal_code') p_postal_code = place.address_components[i]['short_name']; if(addressType == 'street_number') p_street_number = place.address_components[i]['short_name']; if(addressType == 'route') p_route = place.address_components[i]['long_name']; } } else { var place = dropoff.getPlace(); // Get each component of the address from the place details for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if(addressType == 'locality') d_city = place.address_components[i]['long_name']; if(addressType == 'administrative_area_level_1') d_state = place.address_components[i]['long_name']; if(addressType == 'postal_code') d_postal_code = place.address_components[i]['short_name']; if(addressType == 'street_number') d_street_number = place.address_components[i]['short_name']; if(addressType == 'route') d_route = place.address_components[i]['long_name']; } } check_value(action); } function check_value(action) { if(action == 'pickup') { for(var i=0;i < service_names.length; i++) { city_name = service_names[i].toLowerCase().trim(); p_city = p_city.toLowerCase().trim(); if(city_name == p_city) { p_check_status = true; if(p_postal_code) document.getElementById('pickup_zip_hidden').value = p_postal_code; if(p_city) document.getElementById('pickup_city_hidden').value = p_city; if(p_state) document.getElementById('pickup_state_hidden').value = p_state; if(p_street_number) document.getElementById('pickup_street_hidden').value = p_street_number; if(p_route) document.getElementById('pickup_route_hidden').value = p_route; } } if(!p_check_status) { alert('We are not providing the service in this city.'); document.getElementById('pickup_zip').value = ''; return false; } } else { for(var i=0;i < service_names.length; i++) { city_name = service_names[i].toLowerCase().trim(); d_city = d_city.toLowerCase().trim(); if(city_name == d_city) { d_check_status = true; if(d_postal_code) document.getElementById('drop_zip_hidden').value = d_postal_code; if(d_city) document.getElementById('drop_city_hidden').value = d_city; if(d_state) document.getElementById('drop_state_hidden').value = d_state; if(d_street_number) document.getElementById('drop_street_hidden').value = d_street_number; if(d_route) document.getElementById('drop_route_hidden').value = d_route; } } if(!d_check_status) { alert('We are not providing the service in this city.'); document.getElementById('drop_zip').value = ''; return false; } } } // [END region_fillform] function submit_f() { var pattern_zip = new RegExp (/^[0-9]{6,6}$/); if(document.getElementById('pickup_zip').value == '' || document.getElementById('drop_zip').value == '') { alert('Please enter pickup location and dropoff location.'); return false; } if(isNaN(document.getElementById('pickup_zip').value)) { if(!check_city(document.getElementById('pickup_zip').value)) { alert('We are not providing the service in '+document.getElementById('pickup_zip').value+' city.'); return false; } } else { if (!pattern_zip.test(document.getElementById('pickup_zip').value)) { alert('Pickup Pin code is invalid.'); return false; } if(!check_zip(document.getElementById('pickup_zip').value)) { alert('We are not providing the service at '+document.getElementById('pickup_zip').value+' pin code.'); return false; } } if(isNaN(document.getElementById('drop_zip').value)) { if(!check_city(document.getElementById('drop_zip').value)) { alert('We are not providing the service in '+document.getElementById('drop_zip').value+' city.'); return false; } } else { if (!pattern_zip.test(document.getElementById('drop_zip').value)) { alert('Drop-Off Pin code is invalid.'); return false; } if(!check_zip(document.getElementById('drop_zip').value)) { alert('We are not providing the service at '+document.getElementById('drop_zip').value+' pin code.'); return false; } } $('#index_form').submit(); } function check_city(city) { var return1 = false; if((city == 'Bangalore') || (city == 'bangalore')) { city = 'Bengaluru'; } city = city.toLowerCase().trim(); for(var i=0;i < service_names.length; i++) { city_name = service_names[i].toLowerCase().trim(); if(city_name == city) return1 = true; } return return1; } function check_zip(zip) { var return1 = false; zip = zip.toLowerCase().trim(); for(var i=0;i < service_zips.length; i++) { zip_name = service_zips[i].toLowerCase().trim(); if(zip_name == zip) return1 = true; } return return1; }