Solved

Insert Google Map locator in Web site

Posted on 2010-08-19
3
417 Views
Last Modified: 2012-05-10
I have created a very basic web site and would like to create one page that will display a Google Earth map and somehow allow the user to enter GPS coordinates and then have the map go to that location. I have been led to believe that it's meant to be easy to do this but I don't know enough about HTML and Java Script to do it.

Below is some code that creates a page with Google maps. And I've found some code that is supposed to do the lookup I want, but I don't know how to marry the two together. Can anyone help me or is this a big ask?

The following code does the lookup
if (!window.geocodeLocation) {
  window.geocodeLocation = 'City name, country, latitude and longitude, etc';
}

window.geocodeLocation = prompt('Enter a location', window.geocodeLocation);
var geocoder = new google.maps.ClientGeocoder();
geocoder.getLatLng(window.geocodeLocation, function(point) {
  if (point) {
    var lookAt = ge.createLookAt('');
    lookAt.set(point.lat(), point.lng(), 10, ge.ALTITUDE_RELATIVE_TO_GROUND,
               0, 60, 20000);
    ge.getView().setAbstractView(lookAt);
  }
});




The following code creates the map in a web page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Tracker</title>
  <meta name="description" content="Locate & track"/>
  <meta name="Keywords" content="Track" />    
  <link href="StyleSheet.css"rel="stylesheet" type="text/css" />
   <script src="http://www.google.com/jsapi?key=My_Key"  
           type="text/javascript">
   </script>
   
   <script type="text/javascript">
     var ge;
     google.load("earth", "1");

     function init() {
       google.earth.createInstance('map3d', initCB, failureCB);
     }

     function initCB(instance) {
       ge = instance;
       ge.getWindow().setVisibility(true);
     }

     function failureCB(errorCode) {
     }

     google.setOnLoadCallback(init);
     
   </script>
 
</head>
<body>
   <div id="map3d" style="height: 500px; width: 926px;"></div>
</body>
</html>


 
0
Comment
Question by:Rob4077
  • 2
3 Comments
 

Author Comment

by:Rob4077
ID: 33474272
PS, I would prefer not to use a pop up to ask the location but rather just have an input box of some sort. Is that possible?
0
 
LVL 4

Accepted Solution

by:
denissie earned 500 total points
ID: 33474305
0
 

Author Comment

by:Rob4077
ID: 33481298
Hi denissie,
Thanks for the link. It led me to the code that I needed. Appreciate your help
http://code.google.com/apis/maps/documentation/javascript/tutorial.html 
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
edit .asp files 5 31
function parameter and using that as array 15 23
really easy css change help please 4 18
html / css issue / div issue. stuck, help needed 2 14
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question