473,545 Members | 2,639 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"> 
  2.  
  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.      } 
  40.  
  41.     //]]> 
  42.  </script>   
  43.  
Jan 26 '09 #1
3 4486
acoder
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
ziycon
384 Contributor
Got it sorted, got a reply from someone on the gmaps api community.
Jan 26 '09 #3
acoder
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

3
61013
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...
0
1883
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
6
2974
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...
17
4598
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...
1
7272
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,...
5
4004
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
3
7463
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...
3
4413
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
2
2545
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
0
3719
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...
0
7490
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7682
Oralloy
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. ...
0
7935
jinu1996
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...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5351
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3479
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...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.