Link to home
Start Free TrialLog in
Avatar of blossompark
blossomparkFlag for Ireland

asked on

displaying a device using google maps on a website

Hi,
I'm looking for direction regarding a college project.
.i have created a mobile application with java me for  a nokia s60 mobile phone..the app gets  the gps coordinates of  the mobile phone and then sends them to  to another mobile(whose number is embedded in the code) via sms...this works fine
the received message is for example;
http://maps.google.com/maps?q=53.290862915000005%20-6.273899423916
if copied into browser it will bring up google maps with a pointer to the location of  the device...

What I'm trying to do now is send this url directly to my website ( www.blossompark.net) and automatically have the location displayed in google maps, i think i can probably manage to get  the information to the website using  http in Java ME  as outlined in this article(http://wiki.forum.nokia.com/index.php/Using_Http_and_Https_in_Java_ME)

 however i have no clue how to then display the url at  the website.....from what i have googled I'm thinking i need to create a servlet on the website that will accept the url and then (somehow) copy this url into a browser field to display the location....
the core of  the problem is how do i get  the website to receive  the url and then open it  in another page?
any ideas or directions regarding the best way to go with this?
Avatar of rrz
rrz
Flag of United States of America image

You can do it the servlet(or JSP) in a similar way that you did it on the phone.  I'll give you two JSP examples.
I think it would easier to send just the two numbers rather than the whole url.
For example  
myMap.jsp?x=53.290862915000005&y=6.273899423916
<%@ page import="java.util.*,java.net.*,java.io.*" %>
<%
  String x = request.getParameter("x");
  String y = request.getParameter("y");
  if(x != null || y != null ){
             URL url = new URL("http://maps.google.com/maps?q=" + x + "%20-" + y);
             URLConnection con = url.openConnection();
             BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
             String inputLine;
             while ((inputLine = in.readLine()) != null)out.print(inputLine);
             in.close();
  } else {out.print("no data sent!");}
%>

Open in new window

If you can use JSTL, then use  
myMap2.jsp?x=53.290862915000005&y=6.273899423916  
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<c:import url="http://maps.google.com/maps?q=${param.x}%20-${param.y}" />  

Open in new window

Avatar of blossompark

ASKER

Hi,
thanks for your responses...sending just  the two numbers rather  than the whole url seems like a better idea and i will incorporate that into my existing code......as I'm very new to the webserver side of things i have had to do more research on  the basics.  From the little knowledge i have acquired in the past day i'm thinking that using a combination  of php and query strings may be the way to go..
I'm thinking that if i can "package" the device coordinates into  the url query string, that I can then somehow (just researching this bit) trigger a php script to then display the coordinates in a seperate browser page....From the research i've done, it seems that php would be the "easiest" technology for me to get up to speed on....does this strategy  sound feasible to you?
...once again thanks for your responses...
ASKER CERTIFIED SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for your help,really appreciate it..