cancel
Showing results for 
Search instead for 
Did you mean: 

Google maps url in Web dynpro for java

Former Member
0 Kudos

Hi all,

Can someone tell how I can create a Google Url and show this Url in a Iframe in a Web dynpro. I can create an url but I see the google webpage with the map. I just want only see the map in my Iframe!

Kind Regards,

Richard

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kunal,

%20 does not work I used '' instead of <space>. Now have to change the '' to space again in the javascript for the text in the marker!

Kind regards,

Richard

Former Member
0 Kudos

Hi Richard,

visit this link for sample to replace

http://www.w3schools.com/jsref/jsref_replace.asp

http://www.w3schools.com/jsref/jsref_obj_regexp.asp

Actually %20 worked in the sample I test. I had seemingly put of this sort of string - "The%20Taj%20Hotel%20Mumbai"...

Ideally, u can use %20 or +, this to only make sure the well-formedness of URL. You can use any of the character to represent your meaning of space. It doesnot matter afterall unless u make a valid URL out of it..

This aint big hurdle

just google it and you wil sail thru'

http://www.google.co.in/search?hl=en&q=JavaScriptsubstringreplace+example

Edited by: kunal kotak on Jan 19, 2009 9:11 PM

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Kunal,

Thank for your support!!!! The only issue is sending the complete address via de parameter! For the rest it works perfectly.

Kind regards,

Richard

Former Member
0 Kudos

Hi Richard,

My pleasure.

Did you try converting <space> to %20 n vice-versa?

Or is it a different problem? need more details

Former Member
0 Kudos

Hi Kunal Kotak,

Tanks for your input! I still have one issue. My input data like street and city is change during eventing. How can I get my address data in to the html file?

Kind Regards,

Richard

Former Member
0 Kudos

Hi richard,

I am not much clear with what you expect.. can you please be kind to ellaborate more exactly..

As far as i know, i dont think you can key-in or type a address... Maps may not be so precise to give you the results. Is this what you are asking?

-kunal kotak

Former Member
0 Kudos

Hi kunal kotak,

I have build a portal application which is showing me all my outlook contacts. When I select a contact several iViews are triggered by evenenting like Business address. In this iView want to show the business address via Google Maps.

When I select a different contact the Business Address is changed by eventing but I need also change the Google Map. When I test your solution and i works fine when I fill in the addresses in the input fields of the Google Map sample. So If I can send a parameter to your solution I have the solution for my problem.

Kind regards,

Richard

Former Member
0 Kudos

Hi Richard,

One solution that comes to mind is to have a URL parameter embedded. So the path that you have set to the iframe can be extended say for example http://<your path to HTML file in Mimes>?undefined=<address specific to the user>

Next thing to do is extract the URL parameter undefined by JavaScripting. So you can pass the address value to this param.

Once you have this you can trigger this by passing different addresses to URL parameter each time.

Replace the wdDoInit() by following code:


public void wdDoInit()
  {
    //@@begin wdDoInit()
	try {
		String resourcePath = WDURLGenerator.getWebResourceURL(wdComponentAPI.getDeployableObjectPart(), "GoogleMapAPI.html");
								
		wdThis.wdGetContext().currentContextElement().setPath(resourcePath + "?undefined=Mumbai");
		
	} catch (WDURLException e) {
	wdThis.wdGetAPI().getComponent().getMessageManager().reportException(e.getMessage(),true);
	} catch (WDRuntimeException e) {
		wdThis.wdGetAPI().getComponent().getMessageManager().reportException(e.getMessage(),true);
	}
		
    //@@end
  }

Though I have hardcoded the location in above URL, i guess you got what i am indicating at!!

Even after all this, be carefull in preparing the URL which might result invalid URL due to special chars.

For Example: New York will result in invalid URL as <space> is not allowed. Ideally, it would have been New%20York. But then google API will no understand %20. Hence, I recommend you to replace %20 by <space> before calling Google API [You will have to write it in initialize() method of HTML file].

Also, replace the function initialise() in GoogleMapAPI.html


 function initialize() {
      if (GBrowserIsCompatible()) {        
        
        // This function is anonymous, is executed immediately and
	 var query_string = {};
	   var query = window.location.search.substring(1);
	   var vars = query.split("&");
	   for (var i=0;i<vars.length;i++) {
	     var pair = vars<i>.split("=");
		// If first entry with this name
    	 if (typeof query_string[pair[0]] === "undefined") {
	       query_string[pair[0]] = pair[1];
    	   //this.address.value = pair[1];
        	map = new GMap2(document.getElementById("map_canvas"));
       
	        geocoder = new GClientGeocoder();
    	    showAddress(pair[1]);
		
     } 
   }

I hope your address issue is addressed by me now!!

kunal kotak

Former Member
0 Kudos

Hi Richard,

was the solution helpful to you by much extent? Or do you need more clarifications?

regards,

kunal kotak

Former Member
0 Kudos

Hi Richard,

I have got a solution for you. Follow this steps to locate a city or any place by typing in the name in an input box:

1. Create a iFrame with a context value attribute (type string) to store the path.

2. Copy the below HTML file in your Mimes folder and name the file as say GoogleMapAPI.html

http://code.google.com/apis/maps/documentation/examples/geocoding-simple.html

Open this link in new window. Right click on the page and get the source code. Use it as-is. Only change the key as mentioned in following step #4.

3. Write the code to fetch the path of the above mentioned file in wdDoInit() method of the view.


  public void wdDoInit()
  {
    //@@begin wdDoInit()
	try {
		String resourcePath = WDURLGenerator.getWebResourceURL(wdComponentAPI.getDeployableObjectPart(), "GoogleMapAPI.html");
								
		wdThis.wdGetContext().currentContextElement().setPath(resourcePath);
		
	} catch (WDURLException e) {
	wdThis.wdGetAPI().getComponent().getMessageManager().reportException(e.getMessage(),true);
	} catch (WDRuntimeException e) {
		wdThis.wdGetAPI().getComponent().getMessageManager().reportException(e.getMessage(),true);
	}
		
    //@@end
  }

4. Change the key in above HTML file by registering with google. Its free. Sign Up Link= http://code.google.com/apis/maps/signup.html

Please be careful in registering your domain name properly!!

5. Build, Deply and Run.

Note: I have implemented this and so it should work for you.

Caveat Factor: The result will depend on the address you provide in the input box of HTML page. Common places such as major cities, districts, institutions, and other organizations are very well displayed.

For Example: Search for World Trade Center, New York. And you will be happy with the results.

Revert in case you need more info.

Regards,

Kunal Kotak

Edited by: kunal kotak on Jan 15, 2009 12:33 PM

Edited by: kunal kotak on Jan 15, 2009 12:35 PM

Former Member
0 Kudos

visit this blog on Google Maps

/people/prem.mascarenhas/blog/2007/12/11/google-map-services-for-your-siteportal

kunal kotak

Former Member
0 Kudos

Hi all,

Thanks for the reply but I it still does not work. I have used the sample which kunal kotak posted. Has someone a demo Webdynpro project with address and city input fields and show the map in a Iframe?

Kind Regards,

Richard

Former Member
0 Kudos

If the solution works please let me know.

Regards.

Rajat

Edited by: Rajat Jain on Jan 14, 2009 4:24 AM

Former Member
0 Kudos

Hi,

You can simply right click on the link where the google map is shown> View encoding> Create your html or use it in your implementation and provide the link for that.

Hope it helps.

Regards.

Rajat

Edited by: Rajat Jain on Jan 14, 2009 4:21 AM

Former Member
0 Kudos

Hi,

Yes, you can do it by using the URL that comes up when you click on the "Link" anchor on the top right of a Google maps page. Don't use the browser URL.

Open the map you want to show in a normal browser window and then click on the "Link" anchor after the "Print | Send" anchors. You will see a HTML to use for embedding that map on a web site. Use the URL that's mentioned in the "src" attribute of the iframe.

Also check [this|http://www.google.com/intl/en/press/annc/embed_maps.html] press announcement by Google.

Regards,

Satyajit