473,700 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Google Maps JS

384 Contributor
I'm not sure if anyone here would know anything about the google map js, i've tried the google maps api community with no luck.

I have the below code, it loads ok, but when i click on the map it
doesn't place a marker.
What should happen is that when you click on the map it should place a
marker and when clicked on the map a second time that it should place
a marker at the new location and remove the previous one so that there
is only ever one marker on the map??
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript"> 
  3.     //<![CDATA[ 
  4.          function createMarker(point,name) { 
  5.          var marker = new GMarker(point,{title:name}); 
  6.          return marker; 
  7.      } 
  8.      function mapclick(ov,pt) { 
  9.          if (marker) map.removeOverlay(marker); 
  10.          if (pt) { 
  11.                          marker = createMarker(pt,pt.toUrlValue()); 
  12.              map.addOverlay(marker); 
  13.          } 
  14.          var match11 = /\(([-.\d]*), ([-.\d]*)/.exec(pt); 
  15.          if (match11) { 
  16.                          var lat = parseFloat( match11[1] ); 
  17.                          var lon = parseFloat( match11[2] ); 
  18.                          lat = lat.toFixed(6); 
  19.                          lon = lon.toFixed(6); 
  20.          } 
  21.          document.getElementById("lat").value = lat; 
  22.          if(document.getElementById("lat").value == "undefined") { 
  23.                          document.getElementById("lat").value = ""; 
  24.          } 
  25.          document.getElementById("lon").value = lon; 
  26.          if(document.getElementById("lon").value == "undefined") { 
  27.                          document.getElementById("lon").value = ""; 
  28.          } 
  29.      } 
  30.      function load() { 
  31.                  if (GBrowserIsCompatible()) { 
  32.                          var map = new GMap2(document.getElementById("map")); 
  33.                          map.setCenter(new GLatLng(53.558584,-7.987061), 6); 
  34.                          map.addControl(new GLargeMapControl()); 
  35.                          var marker = null; 
  36.                          GEvent.addListener(map,"click",function(overlay,point){mapclick 
  37.  (overlay,point)}); 
  38.                  } 
  39.      } 
  41.     //]]> 
  42.  </script>   
Jan 26 '09 #1
3 4492
16,027 Recognized Expert Moderator MVP
If you can't even get a marker to show up, then you should perhaps take a simple example (Google Maps API Examples - Google Maps API - Google Code) and adapt it.
Jan 26 '09 #2
384 Contributor
Got it sorted, got a reply from someone on the gmaps api community.
Jan 26 '09 #3
16,027 Recognized Expert Moderator MVP
So what was the problem/solution in the end?
Jan 26 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Sean | last post by:
Have you ever wanted to add the great features inherent in Google Maps? Here is how you do it. ============== == STEP ONE == ============== Create a new MS Access form called frmGoogleMap. Size the form to your liking...
by: windandwaves | last post by:
Hi Folk Some of you may find this function useful. It makes it easier to create maps using Google Maps. I link it to a database of points. The main use of the function is that it creates all the javascript needed for Google maps to work. Any questions or comments? Please ask. Nicolaas
by: Sam Carleton | last post by:
Ok, over the years I have read about doing web programing and I have done some real basic stuff. Now I am digging into some real ASP.Net 2.0 and am totally lost some things. I have a master page setup and that is working great. On my contact page I would like to use Google Maps API Version 2 to show a map to my location. Below is the first Google example. I would like to add this to my aspx page that is using the master page. I...
by: MeerkatInFrance | last post by:
There comes a time when you know you are not going to be able to work something out yourself, however hard you try. I have reached that moment. I have a master page and a slave page (or whatever one calls it) All I want to do is show a Google map on the slave page. The map that Google gives as an example when it gives you a key would be just fine. I have searched high and low for a means of doing this but all I could find
by: xahlee | last post by:
Elisp Tutorial: Make Google Earth Xah Lee, 2006-12 This page shows a example of writing a emacs lisp function that creates a Google Earth file, and creates a link to the file, as well a link to Google Map. If you don't know elisp, first take a gander at Elisp Basics. I often write travelogs on my website. If i traveled to Las Vegas, then
by: xml .NET group | last post by:
Is there any book on using ASP.NET for Google Maps. For example, following books: http://www.amazon.com/Beginning-Google-Maps-Applications-Ajax/dp/1590597079/ http://www.amazon.com/Beginning-Google-Maps-Applications-Rails/dp/1590597877
by: Harch84 | last post by:
Hi I am using a javascript for google maps to geocode two locations and I thin want to retrieve the two coordinates and enter them into a Perl Script. Now I have managed to set up the page with the geocoder and the script uses getLatLng() to draw the two points on two different maps. My problem is hw do I assign these coordinates to variables or some means of entering them into my perl scrip? My Javascript code is below: <!DOCTYPE html...
by: Phil Stanton | last post by:
I have a button on a form which when pressed displays a google map of the address. Code is Private Sub Googlemap_Click() MakeURL ("") End Sub
by: H.Schmidt | last post by:
Hi! im would like to get address informations like city, state or zip for a given GPoint. Is it possible (i found nothing in Google maps Api)? Thanks in advance
by: TrevRex | last post by:
Hello, I work for a non-profit in San Diego as a GIS Specialist. I have had to teach myself about some scripting to create some dynamic maps, but I am still very limited in my skills, so I have had to explore the internet in order to discover various tutorials and examples that have led me on a positive path. Right now I am working on a Google Mash-Up that will incorporate over 14,000 records, which will appear as separate markers that...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.