471,887 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

Google Maps JS

384 256MB
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 4279
acoder
16,027 Expert Mod 8TB
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 256MB
Got it sorted, got a reply from someone on the gmaps api community.
Jan 26 '09 #3
acoder
16,027 Expert Mod 8TB
So what was the problem/solution in the end?
Jan 26 '09 #4

Post your reply

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

Similar topics

reply views Thread by windandwaves | last post: by
6 posts views Thread by Sam Carleton | last post: by
17 posts views Thread by MeerkatInFrance | last post: by
1 post views Thread by xahlee | last post: by
5 posts views Thread by xml .NET group | last post: by
2 posts views Thread by H.Schmidt | last post: by
reply views Thread by zermasroor | last post: by

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.