How to display json 'playercoordinates' and display the marker's of all other users in Google map

On click on some button I am calling this javasript function locateMe(labels, newimages) and later calls an makeAjaxCall(currentLatitude, currentLongitude, temLabel, plyrEmail) ajax
function. This ajax calls the servlet ‘PlayerLocation’ and save the user_id, name, latitude and longitude into database

function locateMe(labels, newimages) {

newcords = getLocation();
for (i=0; i< labels.length; i++ ){
var temLabel = labels[i].innerText;
plyrImages = newimages[0].src ;

  userMarker[i] = new google.maps.Marker({
  	position : { lat : currentLatitude, lng : currentLongitude},
  	zoom : 9,
  	icon : 'images/pointer1.PNG',
  	title : temLabel,
  	draggable : true,
  	map : map
  makeAjaxCall(currentLatitude, currentLongitude, temLabel, plyrEmail); 



'makeAjaxCall (), ajax fucntion

function makeAjaxCall (currentLatitude, currentLongitude, temLabel, plyrEmail) {
type: “POST”,
url: “PlayerLocation”,
data: {currentLat: currentLatitude, currentLong: currentLongitude, title: temLabel, email: plyrEmail},
success: function(data){
alert(currentLatitude +", " + currentLongitude + ", " + temLabel + ", " + plyrEmail);




In the ‘PlayerLocation’ servlet response i am sending back the ‘playercoordinates’ list which has the list of all users from database with their user_id, latitude and longitude

> List<PlayerCoordinates> playercoordinates = SoccerUtils.getPlayercoordinates();

String jsonResponse = new Gson().toJson(playercoordinates);
PrintWriter out=response.getWriter();


request.getSession().setAttribute(“playercoordinates”, playercoordinates);
RequestDispatcher rd = request
rd.forward(request, response);

How do I display the json ‘playercoordinates’ and display the marker’s of all other users in Google map and call another function changeMarkerPosition(marker)

Thanks everyone, I find out a way to do this
// Write the jsonResponse to a file as below:

// Create a new FileWriter object to following path
FileWriter fileWriter = new FileWriter(“c:\Work\Project\WebContent\data.json”);

//Writting the jsonObject into sample.json

an then in javascript, I called getJSON function as below to achieve the markers in google map

  >   $.getJSON("data.json", function(json1) {
      $.each(json1, function(key, data) {
        // call Google Map here 

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.