I think my problem here is that the var_set variable is not being passed anyone see something obviously wrong? It's only suppose to be set to 1 when the form is submitted. Thanks... This is the view source I can post with raw php if needed.
Code:<body onload="load(var_set=0);"> <form method="POST" onsubmit="pointonmap(var_set=1);"> <input type="text" name="address" /><input type="submit" value="Add a Point" /> </form> <script type="text/javascript"> var newpoint; var change_loop = 1; var php_lat=new Array(); var php_lng=new Array(); php_lat[0] = 31.046051; php_lng[0] = 34.851612; php_lat[1] = 31.046051; php_lng[1] = 34.851612; //<![CDATA[ function load () { if (GBrowserIsCompatible()) { var gmarkers = []; var i = 0; var point; var bounds = new GLatLngBounds(); var marker; map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); var blueIcon = new GIcon(G_DEFAULT_ICON); blueIcon.image = "images/blue.png"; markerOptions2 = { icon:blueIcon }; if (var_set == 1 ) { change_loop = 2; php_lat[2] = newpoint.lat; php_lng[2] = newpoint.lng; } function createMarker() { marker = new GMarker(point); i++; return marker; } function Process_Addresses() { for (var i=0; i < change_loop; i++) { var lat = php_lat[i]; var lng = php_lng[i]; point = new GLatLng(lat,lng); bounds.extend(point); if ( i == 2) { marker = new GMarker(newestpoint, markerOptions2); i++; } else { marker = createMarker(point); } map.addOverlay(marker); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); } } Process_Addresses(); } else { alert("Sorry, the Google Maps API is not compatible with this browser"); } // This Javascript is based on code provided by the // Community Church Javascript Team // http://www.bisphamchurch.org.uk/ // http://econym.org.uk/gmap/ } function pointonmap() { var_set = 1; var geocoder = new GClientGeocoder(); geocoder.getLocations(document.forms[0].address.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to find that address."); } else { newpoint = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; load(); } }); } //]]> </script> </div> <div id="map" /> </body>



Reply With Quote

Bookmarks