views:

43

answers:

2

I wanna set up a way in which users can place a marker on the map to tell their address and i should be able to extract the lat and long and store it in the database.

Is there somekinda plugin which i can modify and use ?

+1  A: 

Maybe this is what you are looking for:

Im using javascript for this.

here you set a marker from the address.

var address= "denmark Århus";
  geocoder.getLatLng(
                  address,
                  function(point) {
                    if (!point) {
                      alert(address + " not found");
                    } else {
                      map.setCenter(point, 14);
                      map.addOverlay(new GMarker(point, markerOptions));
                      }
                    }
                  ); 
Profeten
i want the user to zoom and the place the marker.. to mark their address. i think your code just finds the address and places a marker. Basically its to allow people to locate a restuarant on the map
Harsha M V
Maybe you can finde your answer here: http://code.google.com/intl/da/apis/maps/documentation/javascript/overlays.html#Iconsor here:http://code.google.com/apis/maps/documentation/javascript/v2/examples/icon-simple.html
Profeten
+1  A: 

First create a function that a accepts a latlng object. This function will add the info to your database and then add the marker if it was successful.

function addRestaurant( latlng ) {
    lat = latlng.lat;
    lng = latlng.lng;
    //Code to add restaurant
    if ( dbase_successful ) {
        var marker = new google.maps.Marker({
         position: latlng,
         title: "Some text"
            map: map //make your map global
        });
    }
}

Then add an event listener on the click event of the map that calls the function you just created. Add this to your map initialize code.

google.maps.event.addListener(map, 'click', function(event) { addRestaurant( event.latlng ) } );

Now when your map is clicked add_restaurant will be called with the latlng of the click event on the map.

Galen
thanks mate....
Harsha M V