function addNewMarker(event) {

			// Marker information to be sent to create a new marker in the db
			datatosend = {
				lat: event.latLng.lat(),
				lng: event.latLng.lng()
			}

			$.ajax({
				type: 'POST',
				url: 'api_responses/new_marker.json',
				contentType: 'application/json; charset=utf-8',
				dataType: 'json',
				data: JSON.stringify(datatosend),
				success: function(data) {

					// [0] because a one object array is returned
					//response = JSON.parse(data)[0];
					response = data[0];
					response.pk = newPK;
					newPK++;
					response.fields.lat = datatosend.lat;
					response.fields.lng = datatosend.lng;
					//response.fields.lat = parseFloat(response.fields.lat);
					//response.fields.lng = parseFloat(response.fields.lng);

					markerArray.push(response)
					addMarker(response)
				},
				error: function(data) {
					alert("Status code: " + data.status + ". Marker could not be added, reload the page or try again later.");
				}
			});

			$("#context-menu").css({"display": "none"});
		}
// For adding a COMPLETELY NEW marker, DIFFERENT FROM addMarker(). This will add it to markerArray as well
For adding a COMPLETELY NEW marker, DIFFERENT FROM addMarker(). This will add it to markerArray as well
For adding a COMPLETELY NEW marker DIFFERENT FROM addMarker () . This will add it to markerArray as well
function addNewMarker(event) {
			datatosend = {
				lat: event.latLng.lat(),
				lng: event.latLng.lng()
			}
			$.ajax({
				type: 'POST',
				url: 'api_responses/new_marker.json',
				contentType: 'application/json; charset=utf-8',
				dataType: 'json',
				data: JSON.stringify(datatosend),
				success: function(data) {
					response = data[0];
					response.pk = newPK;
					newPK++;
					response.fields.lat = datatosend.lat;
					response.fields.lng = datatosend.lng;
					markerArray.push(response)
					addMarker(response)
				},
				error: function(data) {
					alert("Status code: " + data.status + ". Marker could not be added, reload the page or try again later.");
				}
			});
			$("#context-menu").css({"display": "none"});
		}
function addNewMarker ( event ) { datatosend = { lat : event . latLng . lat ( ) , lng : event . latLng . lng ( ) } $ . ajax ( { type : 'POST' , url : 'api_responses/new_marker.json' , contentType : 'application/json; charset=utf-8' , dataType : 'json' , data : JSON . stringify ( datatosend ) , success : function ( data ) { response = data [ 0 ] ; response . pk = newPK ; newPK ++ ; response . fields . lat = datatosend . lat ; response . fields . lng = datatosend . lng ; markerArray . push ( response ) addMarker ( response ) } , error : function ( data ) { alert ( "Status code: " + data . status + ". Marker could not be added, reload the page or try again later." ) ; } } ) ; $ ( "#context-menu" ) . css ( { "display" : "none" } ) ; }
For adding a COMPLETELY NEW marker, DIFFERENT FROM addMarker().
For adding a COMPLETELY NEW marker DIFFERENT FROM addMarker () .
// Marker information to be sent to create a new marker in the db // [0] because a one object array is returned //response = JSON.parse(data)[0]; //response.fields.lat = parseFloat(response.fields.lat); //response.fields.lng = parseFloat(response.fields.lng);