6 examples of 'get lat long from address google api' in JavaScript

Every line of 'get lat long from address google api' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
357function format_lat_long(latorlong) {
358 var loc_arry = latorlong.split(",");
359 var degree = parseFloat(loc_arry[0]);
360 var minutes = parseFloat(loc_arry[1]);
361 var seconds = parseFloat(loc_arry[2]);
362 var formatted = degree + ((minutes * 60) + seconds) / 3600;
363
364 return formatted;
365}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

27function getLatLongFromLocation(itemData, callback)
28{
29 if (callback === undefined) {
30 callback = function (data0 ) {
31 osg.log("location for " + data0.location);
32 osg.log(data0);
33 };
34 }
35 var str = itemData.user.location;
36 //osg.log("place to find " + str);
37 if (CacheLocation[str] === undefined) {
38 var url = "http://ws.geonames.org/searchJSON?q=" + str +"&maxRows=10&callback=?";
39 //osg.log("url " + url);
40 jQuery.getJSON(url, function(data) {
41 if (data.totalResultsCount !== undefined && data.totalResultsCount > 1) {
42 var item = data.geonames[0];
43 //osg.log(item);
44 CacheLocation[str] = { 'lat': item.lat, 'lng': item.lng};
45 } else {
46 CacheLocation[str] = {'lat' : 0, 'lng': 0};
47 }
48 CacheLocation[str].location = str;
49 callback(CacheLocation[str], itemData);
50 });
51 } else {
52 callback(CacheLocation[str], itemData);
53 }
54}
412MapUtility.lat = function lat(position) {
413 if (position instanceof Array) {
414 return position[0];
415 } else if (position.lat instanceof Function) {
416 return position.lat();
417 } else {
418 return position.lat;
419 }
420};
31MapUtility.lat = function lat(position) {
32 if (position instanceof Array) {
33 return position[0];
34 }
35 else if (position.lat instanceof Function) {
36 return position.lat();
37 }
38 else {
39 return position.lat;
40 }
41};
78get LatitudeRaw() {
79 return this[s_latitude];
80}
20function geo2loc(lnglat, cb) {
21 request('GET http://restapi.amap.com/rgeocode/simple', {
22 resType: 'json',
23 encode: 'utf-8',
24 range: 3000,
25 roadnum: 0,
26 crossnum: 0,
27 poinum: 0,
28 retvalue: 1,
29 sid: 7001,
30 region: [lnglat.lng, lnglat.lat].join(',')
31 }, function(err, res) {
32 if (err) {
33 error('geo2loc failed', err);
34 return cb();
35 }
36 var r, loc_name;
37 try {
38 r = res.list[0];
39 loc_name = r.city && r.city.name || r.province.name;
40 } catch (e) {
41 error('geo2loc failed', res);
42 return cb();
43 }
44 return cb({
45 city: loc_name,
46 place: r
47 });
48 });
49};

Related snippets