I need to select data from a mysql database and handle it with angularjs. I have a database with a table called “mapas”. The columns are id, lat and lng. lat and lng are strings that stores coordinates. Someone can teach me how to select lat and lng from the database and store it on a variable with angularjs? I’ll always have only one line on the table. Would be nice to get the data in a json like this: {“lat”: “-21.2292703”, “lng”: “-44.9775718”}
uploading a file i handle it like this:
$scope.uploadFile = function ($event) {
var files = $event.target.files;
var jsonCoords;
var file = files[0];
var reader = new FileReader();
reader.onload = function (event) {
jsonCoords = JSON.parse(event.target.result);
var mapProp = {
center: new google.maps.LatLng(jsonCoords.lat, jsonCoords.lng),
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
document.getElementById("formJsonFile").reset();
var marker = new google.maps.Marker({
position: new google.maps.LatLng(jsonCoords.lat, jsonCoords.lng),
map: map,
title: 'Coordenada: ' + jsonCoords.lat + ',' + jsonCoords.lng
});
}
reader.readAsText(file)
};
Selecting from mysql i would do the same thing, but the coords would come from the select.
Thank you
Source: AngularJS
from Angular Questions https://angularquestions.com/2017/10/02/select-data-from-mysql-with-angularjs/
via @lzomedia #developer #freelance #web #lzomedia.com
No comments:
Post a Comment