Saving Marker Locations into the database(SQLServer) in Google Map

I am pretty new to web programming especially to Google Api for Maps. Is it possible to save the geocodes or latitude /logitude values of markers that are created in the database. This is because the next time the page loads the Markers should be in the same position as last left by the user. I dont mean cache here.
Any sample code for this purpose will be greatly appreciated.
LVL 2
rupvisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

asafadisCommented:
I found a pretty straightforward post from someone else in your same situation:
http://stackoverflow.com/questions/1746230/google-maps-add-a-marker-to-map-then-store-latitude-and-longitude-in-ruby-on-rai

In his case, he needed a Ruby On Rails solution, however the code is simple and self-explanatory enough for you to interpret it and "translate" it into JSP.

NOTE: JavaScript doesn't have access to the database.  In fact it doesn't know what a database is!  You'll have to make an AJAX call to a JSP page that will receive some parameters and perform the necessary database functions.  The guy in the post recommends jQuery... so do I!

Your script should look something like:
/* JAVASCRIPT */

draggable_marker = new GMarker(new GLatLng(42.6976489, 23.3221545), {draggable : true,title : "Place this marker to your location");

GEvent.addListener(draggable_marker, 'dragend', function() {  
    savePosition(draggable_marker);
});

function savePosition(marker) {
    var title = marker.getTitle();
    var lat   = marker.getLatLng().lat();
    var lng   = marker.getLatLng().lng();
    
    // jQuery Part
    $.ajax({
        type: "GET",
        url: "someJSPPageToDoDatabaseFunctions.jsp",
        data: "title=" + title + "&lat=" + lat + "&lng=" + lng,
        success: function(msg){
            alert( "Data Saved: " + msg );
        }
    });
}

/* someJSPPageToDoDatabaseFunctions.jsp */
I'm not that familiar with JSP, but write a script that will interpret a URL like:
    someJSPPageToDoDatabaseFunctions.jsp?title=FootLocker&lat=42.6976489&lng=23.3221545

Once you catch these values, save them!

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.