Skip to Content
Technical Articles
Author's profile photo Rahul Patra

Location fetching based on typed address & address fetching based on entered Latitude & Longitude in SAP UI5

Hi Readers!

First of all Happy New Year to all.This is another interesting topic,

Problem Statement

1. Sometimes we had implemented google map in our application but after searching any address manually, we are unable to show the location on the google map.

2. If we have Latitude & Longitude we are unable to fetch the Address of that particular Lat & Log.

This blog will help you on that.


Here I will provide solution one by one.

1. Fetching Location based on Address

If we use any search box at the top of our google map, there we can write any address, we need to display the location on my google map with a marker.

Here I am writing the code, after entering the address when you click on the search button.

 onSearch: function () {  
	        var map =;  
	        var address = this.getView().byId("SearchInput").getValue();  
	        var geocoder = new google.maps.Geocoder();
	        this.geocoder.geocode({ 'address': address }, function (results, status) {  
	            if (status == google.maps.GeocoderStatus.OK) {  
	                var marker = new google.maps.Marker({  
	                    map: map,  
	                    position: results[0].geometry.location  
	            } else {  
	      "Geocode was not successful for the following reason:"+ status);

You will able to have one marker on the entered address on google map.

2. Address Fetching from Lat & Log

Now, sometimes we have Latitude & Longitude but need to have the address. Below code will help on this

var lat= " " ;
var log= " " ;
var latLng = new google.maps.LatLng(lat,log);
	                        latLng: latLng     
	                           if (responses && responses.length > 0) 
		                        	var formatedAddress=responses[0].formatted_address;
		                      "You have selected : " + formatedAddress,);
	                   'Not getting Any address for given latitude and longitude.');     

Thank you for reading this blog.

Rahul Patra
SAP-Fiori Consultant.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Dear Rahul,


      I want latitude and longitude as per state wise.

      i have to plot the map and every state i want to show the colour and status bar.



      Umesh k