Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2010-01-13
Medium Priority
Last Modified: 2012-05-08
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.
Question by:rupvis
1 Comment
LVL 11

Accepted Solution

asafadis earned 2000 total points
ID: 26312606
I found a pretty straightforward post from someone else in your same situation:

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:

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() {  

function savePosition(marker) {
    var title = marker.getTitle();
    var lat   = marker.getLatLng().lat();
    var lng   = marker.getLatLng().lng();
    // jQuery Part
        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:

Once you catch these values, save them!

Open in new window


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is designed to assist GIS (Geographic Information System) and GPS (Global Positioning System) developers using ESRI ArcGIS and other spatial information management systems.   For the uninitiated the concept of projectio…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question