Question

User Current Location

Asked by: xenia27

I am trying to create a Java web application with google api.  I will be able to locate a user's location and mark it on the google map. Then, I need to store the information of user's location. How exactly I can do this?

I try to use google.loader.ClientLocation with JavaScript to get user's information.  So, I tried to call through Java; therefore, I can store information into some table.  However, I keep having some error message said "some variable is not defined" or "google is not defined".

What can I do to make this work?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-07-03 at 00:36:14ID24541740
Topics

Java Programming Language

,

JavaScript

Participating Experts
4
Points
500
Comments
47

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. openinfowindow in google maps API
    I'm trying to get the openinfowindow function working. currently my code looks like this, how can I implement the openinfowindow, I've been trying different things none of which seem to work. Have to give credit to Mike Williams for the code, but I could not find a beginners...
  2. How to access to google maps API from java application?
    I am working on Java application, J2ee, (struts, Hibernate), when user enter the location at "add my location", right now, the user can enter any city the application currently will take whatever the entry and save it into our database, now i need to validate the e...
  3. Joogle API.. for google maps
    Hi all, I am trying to use JOOGLE api for google maps. I want to show a map of a selected location through Gogle Maps API. The problem that i am facing is that google maps API is a javascript api, i want to use and do all my business logic in Java and not in java scrip, reaso...
  4. Combining PHP and Javascript (Google Map's API)
    I came across some code on Google's API page regarding reverse geocoding. I've been going over it trying to figure out how to mod the output to my needs. Since I know no Javascript, I've come here for help. Heres the process: Mysql Query to call up last posted latitude/lo...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: CEHJPosted on 2009-07-03 at 01:07:31ID: 24770733

>>So, I tried to call through Java

How? Please post code

 

by: fsze88Posted on 2009-07-03 at 01:09:44ID: 24770749

I need to store the information of user's location?
could you try store user's information into cookies?

 

by: xenia27Posted on 2009-07-03 at 01:09:55ID: 24770751

Error Message...
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "cl" is not defined. (<Unknown source>#1) in <Unknown source> at line number 1
      at com.sun.script.javascript.RhinoScriptEngine.invoke(Unknown Source)
      at com.sun.script.javascript.RhinoScriptEngine.invokeFunction(Unknown Source)
      at com.unet.googleproject.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:44)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:166)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
      at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:54)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
      at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:306)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
      at org.mortbay.jetty.Server.handle(Server.java:313)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
      at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

my html file...
  	<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true">
 
	var cl;
  	google.load("maps", "2.x");
    if (google.loader.ClientLocation)
        cl = google.loader.ClientLocation;
    function GetClientLatitude()
    {
 
        return cl.latitude;
    }
 
    function GetClientLongitude()
    {
        return cl.longitude;
    }
    
    function sumTwoValue(var1, var2)
    {
        return var1 + var2;
    }
 
    </script>
 
my java file...
		// getting engine
		ScriptEngineManager mgr = new ScriptEngineManager();
		ScriptEngine jsEngine = mgr.getEngineByName("JavaScript");
		Invocable invocableEngine = (Invocable)jsEngine;
		String value = new String();
 
		try {
		jsEngine.eval("function GetClientLatitude() {" +
		" return cl.latitude;" +
		"}");
 
 
		// (Java-|ëScript Method&púÞ³<
		System.out.println("return value from javascript is : " +
		invocableEngine.invokeFunction("GetClientLatitude"));
		value = invocableEngine.invokeFunction("GetClientLatitude").toString();
 
		} catch (ScriptException ex) {
		ex.printStackTrace();
		} catch (NoSuchMethodException ex) {
		ex.printStackTrace();
		}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:

Select allOpen in new window

 

by: xenia27Posted on 2009-07-03 at 01:10:53ID: 24770756

What's wrong with my code?

Cookie?  Which one is easiest one?

 

by: b0lsc0ttPosted on 2009-07-03 at 01:11:08ID: 24770758

xenia27,

Java and Javascript are two completely different languages and run at different times in a web page's "life."  Java would be done by the server or maybe an applet; Javascript is run by the browser.  This is why variables of one won't be available to the other.

What exactly do you mean a Java web app?  Google's API uses Javascript and you would use Javascript to work with it in your browser.  At least the part that is used for maps?  What is the code you are trying to use to locate the location?  What API exactly?  The ClientLocation property I have seen in Google's API is related to their AJAX API.  It is Javascript which is used to work with it.  If you are having a problem with it then please provide more specifics on the code and when this problem occurs in relation to what you are doing.

Let me know if you have any questions or need more information.

b0lsc0tt

 

by: CEHJPosted on 2009-07-03 at 01:13:02ID: 24770772

>>if (google.loader.ClientLocation)

probably evaluated to false

 

by: xenia27Posted on 2009-07-03 at 01:17:40ID: 24770796

How can I avoid this situation?

 

by: CEHJPosted on 2009-07-03 at 01:39:34ID: 24770885

>>How can I avoid this situation?

You need to check that it's not null first. See http://code.google.com/apis/ajax/documentation/#ClientLocation

 

by: objectsPosted on 2009-07-03 at 02:13:54ID: 24771063

as b0lsc0tt points out above (and you appear to have ignored) you're not loading the google js, or creating cl.
What you do in your html is completely independent to what you do in your java code.
ie. your html has nothing to do with your problem, you need to load the google js, and create cl in your *java* code if that where you want to use it.
Or make the call in your html (instead of java) and update the html dynamically.

 

by: CEHJPosted on 2009-07-03 at 02:18:30ID: 24771086

>>you're not loading the google js

That's not the case, it is being loaded, or an attempt is being made.

But don't you need a key as part of the query string?

 

by: CEHJPosted on 2009-07-03 at 02:21:29ID: 24771098

There's absolutely no guarantee that ClientLocation will be valid, even when the js is loaded in the most ideal way, as described in the link i posted

 

by: b0lsc0ttPosted on 2009-07-03 at 10:37:21ID: 24773632

Java isn't my expertise so may be it does have a way to run Javascript as a browser would and get and results or responses.  I do know a key is a required part of the request to Google's API.  Let me know if you need info on how to get it.

This actually brings us to a possible issue.  Even if Java provides a way to do it the key is tied to a domain.  Although the key can also work for "localhost" test it won't work from just anywhere.  This may be an issue that will cause your efforts to not work but I don't know enough about how Java would use the script to know for sure.

Let me know if you have a question or how this helps.

bol

 

by: objectsPosted on 2009-07-03 at 20:02:14ID: 24775528

b0lsc0tt,

your initial analysis of the cause of the problem was correct :)

 

by: xenia27Posted on 2009-07-05 at 19:37:43ID: 24782201

OK...here is what I try to do..
This is what I try to do...
When a user login on the web page, I can locate which city (even the exac location) of this user.  So the user can explorer the nearby product around this user.

I need to show the location and other products' location on a map; hence, I would love to have a google map on my web page.  Also, there will be more functions in Java program, then, I want to figure how I can get the information of the user's location.

Not sure whether this information is enough...

Still trying to work on the tips above...

 

by: objectsPosted on 2009-07-05 at 19:49:59ID: 24782229

Have you fixed up your java code to include all the javascript you need yet?
Why are you making the calls from java in the first place instead of directly from your html?

 

by: objectsPosted on 2009-07-05 at 19:57:00ID: 24782257

executing it in your java would not appear to be what you want.

 

by: xenia27Posted on 2009-07-05 at 22:11:55ID: 24782688

Nope, not yet...sorry for taking so long.  I would love to use google api in my html and get the values from my html to my java program.  Will this work?

Or, is there other ways to get values from my html to my java program?

 

by: objectsPosted on 2009-07-05 at 22:17:28ID: 24782709

>  would love to use google api in my html and get the values from my html to my java program.

you would just post them, but why do you need them in your java program?

 

by: xenia27Posted on 2009-07-05 at 22:19:47ID: 24782724

because I need to store these information into a database and when the particular user login again, the program will show these information again.  There are also some statistics calculation involved and email notifications, etc.

 

by: xenia27Posted on 2009-07-05 at 22:21:43ID: 24782737

I am confused that how I can start modify my programs now...

 

by: objectsPosted on 2009-07-05 at 22:24:21ID: 24782751

I'd suggest doing all your javascript calls in your html, and posting any details you need to store to your server. Running js with Java the way you are doing it will not work.

 

by: xenia27Posted on 2009-07-05 at 22:30:35ID: 24782787

how I can store the information so my server program can get them?  Is there any web site I can study?

 

by: objectsPosted on 2009-07-05 at 22:35:10ID: 24782809

 

by: xenia27Posted on 2009-07-05 at 23:26:00ID: 24782977

a little bit of confused still..but working on it now...

 

by: xenia27Posted on 2009-07-05 at 23:54:07ID: 24783071

so I should use html to get the values I want and use POST/GET in my java program to have the values from html?

 

by: objectsPosted on 2009-07-06 at 00:09:35ID: 24783135

no you would POST/GET them from the javascript by making a call to your server

 

by: xenia27Posted on 2009-07-06 at 00:11:02ID: 24783144

I see...let me try~~

 

by: CEHJPosted on 2009-07-06 at 00:27:47ID: 24783202

>>I am confused that how I can start modify my programs now...

The link i posted way back tells you all you need to know. You simply need to do this on the client in JavaScript and the link shows you how to use Ajax in this regard

 

by: xenia27Posted on 2009-07-06 at 01:27:03ID: 24783401

I tried to copy and paste the codes in the link aboved...and I kept having some error messages on the following line..
var mygetrequest=new ajaxRequest()
mygetrequest.onreadystatechange=function(){
 if (mygetrequest.readyState==4){
   document.getElementById("result").innerHTML=mygetrequest.responseText
 }
}  <-- error message here...said need an object

Any idea what's wrong?

 

by: xenia27Posted on 2009-07-06 at 01:31:45ID: 24783419

Never mind...I got what's wrong....still working on the example~

 

by: CEHJPosted on 2009-07-06 at 01:35:02ID: 24783426

Using a general API is not going to help you. Use the *specific* location API at the link i provided

 

by: b0lsc0ttPosted on 2009-07-06 at 18:21:08ID: 24790786

In case there may be some confusion the AJAX code recently posted (see http:#a24783401) is not an API.  It isn't Google's either.  I am actually not really sure why it is needed.  You need these results in your Java code, right?  Have you tried just a basic test (i.e. a Google Search API) to see if your Java will get the response?  I wouldn't spend lots of time on details of this until you verify the basics will work.  Because of the way the Google API works I am afraid you won't be able to use it like you want.

This was mentioned earlier but you do know the ClientLocation results may not work and aren't very specific?  I just mention this because if you have to always get a location or need it to be more accurate than it is designed then you might as well stop now.  Google's Client Location does have some limitations.

Let me know if you have a question or need more info.

bol

 

by: objectsPosted on 2009-07-06 at 18:29:12ID: 24790817

the code used to call from java was never going to work as it was trying to access vars from the html

 

by: xenia27Posted on 2009-07-06 at 19:01:44ID: 24790936

OK...I quit my current program and start a new one using Javascript to get user's location as you guys suggested above.  Just delete the old program and start a new one since I was messed up my program already.

Is there any way that I can know the exact location without keyin by users?

 

by: b0lsc0ttPosted on 2009-07-06 at 19:07:36ID: 24790963

If you have a Google Maps API key set up try using the code below.  It uses Javascript and loads the Maps API to then get CurrentLocation.  It is the basic way to get the location (if the script can get it).  Keep in mind loading any of the Google APIs should make it so you can use the CurrentLocation code.  This uses Maps because it is a common use and simple example but you don't have to have a map on your page, etc.

Let me know if you have a question or how this works.  If you need help using it then let us know.

bol

p.s.  Don't forget to enter your key in the first script tag where you see "YOURKEYHERE".

<!--
 Copyright 2008 Google Inc. 
 Licensed under the Apache License, Version 2.0: 
 http://www.apache.org/licenses/LICENSE-2.0 
 -->
<html>
<head>
  <script type="text/javascript" src="http://www.google.com/jsapi?key=YOURKEYHERE"></script>
  <script>
  google.load("maps", "2", {callback: initialize});
 
  function initialize() {
    // Initialize default values
    var zoom = 3;
    var latlng = new google.maps.LatLng(37.4419, -100.1419);
    var location = "Showing default location for map.";
 
    // If ClientLocation was filled in by the loader, use that info instead
    if (google.loader.ClientLocation) {
      zoom = 13;
      latlng = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
      location = "Showing IP-based location: <b>" + getFormattedLocation() + "</b>";
    } 
   
    document.getElementById("location").innerHTML = location;
    var map = new google.maps.Map2(document.getElementById('map'));
    map.setCenter(latlng, zoom);
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
  }
 
  function getFormattedLocation() {
    if (google.loader.ClientLocation.address.country_code == "US" &&
      google.loader.ClientLocation.address.region) {
      return google.loader.ClientLocation.address.city + ", " 
          + google.loader.ClientLocation.address.region.toUpperCase();
    } else {
      return  google.loader.ClientLocation.address.city + ", "
          + google.loader.ClientLocation.address.country_code;
    }
  }
 
</script>
</head>
<body>
<div style="width:500;height:300" id="map"></div>
<div id="location"></div>
</body>
</html>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:

Select allOpen in new window

 

by: b0lsc0ttPosted on 2009-07-06 at 19:08:30ID: 24790967

Oops ... instead of CurrentLocation it should probably be ClientLocation.  I think the point is still clear but don't want to confuse this.

bol

 

by: xenia27Posted on 2009-07-06 at 19:26:23ID: 24791026

to b0lsc0tt,
I copied and pasted your code aboved, and I got this error message...said "Line: 36  The object does not support this attribute or method" (I am not sure what exact this error message is in English)  And line 36 is line 8 in the code aboved.

what should I do?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
 Copyright 2008 Google Inc. 
 Licensed under the Apache License, Version 2.0: 
 http://www.apache.org/licenses/LICENSE-2.0 
 -->
 
<!-- The HTML 4.01 Transitional DOCTYPE declaration-->
<!-- above set at the top of the file will set     -->
<!-- the browser's rendering engine into           -->
<!-- "Quirks Mode". Replacing this declaration     -->
<!-- with a "Standards Mode" doctype is supported, -->
<!-- but may lead to some differences in layout.   -->
 
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
 
    <!--                                                               -->
    <!-- Consider inlining CSS to reduce the number of requested files -->
    <!--                                                               -->
    <link type="text/css" rel="stylesheet" href="XeniaNet.css">
 
    <!--                                           -->
    <!-- Any title is fine                         -->
    <!--                                           -->
    <title>Web Application Starter Project</title>
    
    <!--                                           -->
    <!-- This script loads your compiled module.   -->
    <!-- If you add any GWT meta tags, they must   -->
    <!-- be added before this line.                -->
    <!--                                           -->
    <script type="text/javascript" language="javascript" src="xenianet/xenianet.nocache.js"></script>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAfY2iSWaI4XX7aNUo-orecBQqqM2Hu6GCM5KAICnzfaDmWdVsMBT6njvj6tjPmPnRX0ayG5_cz81O0w" type="text/javascript"></script>
    <script>
    	google.load("maps", "2", {callback: initialize});
    	function initialize() {
    		// Initialize default values
    		var zoom = 3;
    		var latlng = new google.maps.LatLng(37.4419, -100.1419);
    		var location = "Showing default location for map.";
    		 
    		// If ClientLocation was filled in by the loader, use that info instead
    		if (google.loader.ClientLocation) {
    			zoom = 13;
    		    latlng = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
    		    location = "Showing IP-based location: <b>" + getFormattedLocation() + "</b>";
    		} 
    		   
    		document.getElementById("location").innerHTML = location;
    		var map = new google.maps.Map2(document.getElementById('map'));
    		map.setCenter(latlng, zoom);
    		map.addControl(new GLargeMapControl());
    		map.addControl(new GMapTypeControl());
    	}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:

Select allOpen in new window

 

by: xenia27Posted on 2009-07-06 at 19:33:57ID: 24791055

now I removed the original html and copied your code and I got error message on line 4 said "must have '}'"

 

by: xenia27Posted on 2009-07-06 at 19:50:29ID: 24791107

ok..I figured out what's wrong...need this line <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> in my <head> section.

 

by: xenia27Posted on 2009-07-06 at 19:51:55ID: 24791114

so now I need to use POST/GET to communicate with my server program (in java)?

 

by: b0lsc0ttPosted on 2009-07-06 at 20:06:19ID: 24791167

So does the page I provided work now just as an html page opened up in your browser?  Make sure you are testing it from your domain or as a "localhost" site.  If it does work then great.  Let me know if you need anything else as far as an html page that will do this.

>> so now I need to use POST/GET to communicate with my server program (in java)? <<

Isn't that back to what you decide to drop because it wasn't going to work?  Don't really understand what you mean and it seems like that is a line you said earlier about stuff you now know won't give the result you wanted.  Let me know if you think I have misread this.  Also if you are asking for help with that then please be more specific.  The sentence seems like a statement except it ends with a question mark.  I am not real sure what the question is.

bol

 

by: objectsPosted on 2009-07-06 at 20:16:14ID: 24791201

> Isn't that back to what you decide to drop because it wasn't going to work?

no, the original approach was trying to access the js from the java code.
you need to do it the other way round, ie your js call the server

 

by: xenia27Posted on 2009-07-06 at 20:19:48ID: 24791216

to b0lsc0tt,
the html works...now i need to move on to the next step...Thanks!!!

to objects,
what do you mean by the other way?  so calling my server from my js means using POST and GET?  Just wanna make sure before I move on..

 

by: objectsPosted on 2009-07-06 at 20:21:47ID: 24791223

> so calling my server from my js means using POST and GET?  

yes

 

by: xenia27Posted on 2009-07-06 at 20:25:36ID: 24791248

ok...thanks everyone~~~~

 

by: CEHJPosted on 2009-07-07 at 02:01:22ID: 24792513

xenia27, why did you mark http:#24782809 as the accepted answer? It's not relevant to your requirement and is an approach you correctly rejected ...

 

by: xenia27Posted on 2009-07-07 at 02:06:42ID: 24792538

mMmm...it helps me how to communicate with my server program (Java)...that's why I accepted that answer.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...