All posts by kathirprakash

Get latitude | longitude using address in Goolge Map

Step  1

Include  Google map api with  key and libraries
<script                                                                                                                                                                                                     src=”https://maps.googleapis.com/maps/api/js?key=AIzaSyAzXoaC9OV09c- sTdIWWR1hWzUcJppx_g8&libraries=places”></script>

Step 2

Create div tag for map with id

<div id=”location_map” style=”width:500px; height:500px;”></div>

Step 3

Create Address input field with latitude and longitude

<div>Address</div>
<div><input type=”text” name=”loc_address” id=”loc_address” value=”” style=”width:400px; height:40px;” /> </div>

<div>Latitude</div>
<div> <input type=”text” name=”loc_latitude” id=”loc_latitude” value=”” style=”width:300px; height:40px;” /> </div>

<div>Longitude</div>
<div> <input type=”text” name=”loc_longitude” id=”loc_longitude” value=”” style=”width:300px; height:40px;” /> </div>

Step  4

Include this script

<script>
Location_map();
function Location_map() {

var Loc_map = new google.maps.Map(document.getElementById(‘location_map’), {
center: {lat: 34.8375, lng: -106.2370},
zoom: 10
});
var location_input = (document.getElementById(‘loc_address’));

var autocomplete = new google.maps.places.Autocomplete(location_input);
autocomplete.bindTo(‘bounds’, Loc_map);

var loc_marker = new google.maps.Marker({
map: Loc_map,
anchorPoint: new google.maps.Point(0, -29)
});

autocomplete.addListener(‘place_changed’, function() {

loc_marker.setVisible(false);
var place = autocomplete.getPlace();

if (place.geometry.viewport) {

Loc_map.fitBounds(place.geometry.viewport);
}
else {
Loc_map.setCenter(place.geometry.location);
Loc_map.setZoom(17);
}
loc_marker.setPosition(place.geometry.location);
loc_marker.setVisible(true);

$(‘#loc_latitude’).val(place.geometry.location.lat());
$(‘#loc_longitude’).val(place.geometry.location.lng());

});

}

</script>

Step  5

when  type in address field,  address will be loaded automatically and latitude and longitude will be placed in input fields for searching address.

 

Completed

TEST THE SITE IN SHARED HOSTING BEFORE SWITCHING THE DNS RECORDS

Before Mapping the Domain and switching the DNS records, we could test the development site in shared hosting using below Options!

For Windows 7 and vista

Step 1. Open the folder C:\Windows\System32\drivers\etc

 

 

 

Step 2.  Double-click on the ‘hosts’ file and choose the Notepad from the list of available software:

host

 

notepad

 

 

Step 3.  Input the following strings in the end of the document:

Domain

Example

IP_address domainname.com
IP_address www.domainname.com

where IP_address is the IP address of your account on the server (it can be found in the Hosting Welcome Email), and domainname.com is your actual domain name:

Step 4. Save the changes.

Completed

 

For Windows 8 or 8.1:

Step 1. Open Notepad with Administrative privileges by clicking Start button

Step 2. Find Applications > type Notepad in search bar and then right-click Notepad and select to Run as Administrator:

Step 3. Once Notepad is opened with Administrative privileges click the File menu > choose Open:

Step 4. Browse to C:\Windows\System32\drivers\etc (you may simply copy this path to address bar and click Enter):

Step 5. Click to show All Files:

Step 6. Choose ‘hosts‘ file and click Open:

Step 7. Insert the following strings in the end of the document:

IP_address  domainname.com
IP_address  www.domainname.com

where IP_address is the IP address of your account on the server (it can be found in the Hosting Welcome Email), and domainname.com is your actual domain name:

Step 8. Save changes.

completed

 

For Mac OS:

STEP  1. Open the Terminal.app, either by start typing Terminal on the Spotlight, or by going into Applications >Utilities > Terminal:

STEP  2. Open the hosts by typing on the Terminal that you have just opened:
sudo nano /private/etc/hosts

STEP  3. Type your user password when prompted (you can navigate the file using the arrow keys).

STEP  4. Edit the hosts file appending your new mappings underneath the default ones:

IP_address domainname.com
IP_address www.domainname.com

where IP_address is the IP address of your account on the server (it can be found in the Hosting Welcome Email), and domainname.com is your actual domain name:

STEP  5. Save the hosts file (when done editing the hosts file, press CTRL+O to save the file > press Enter on the filename prompt > Ctrl+X to exit the editor).

STEP  6. Flush the DNS cache (you can issue a simple Terminal command to flush the DNS cache depending on the version of OS X you are using and have your host file changes to take immediate effect).

NOTE: After completed the testing OR Once Domain mapped to the server, you need to revert the changes back. So, you need to remove the new entries added to your host file or simply comment them by adding ‘#’ at the beginning of each line, then save the changes.

Completed