Every line of 'get latlng from address google maps' 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.
20 function 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 };
3 export function latLngToArray(latLng) { 4 const latitude = latLng.lat(); 5 const longitude = latLng.lng(); 6 return [latitude, longitude]; 7 }
17 export function constructLocation (latlng) { 18 return { 19 name: latlngToString(latlng), 20 lat: latlng.lat, 21 lon: latlng.lng 22 } 23 }
39 function addGeocodingToMarker(marker,address){ 40 marker.orig_initialize = marker.initialize; 41 orig_redraw = marker.redraw; 42 marker.redraw = function(force){}; //empty the redraw method so no error when called by addOverlay. 43 marker.initialize = function(map){ 44 new GClientGeocoder().getLatLng(address, 45 function(latlng){ 46 if(latlng){ 47 marker.redraw = orig_redraw; 48 marker.orig_initialize(map); //init before setting point 49 marker.setPoint(latlng); 50 }//do nothing 51 }); 52 }; 53 return marker; 54 }
1 export function returnCoord(latlng) { 2 const lat = parseFloat(latlng.split(",")[0]); 3 const lng = parseFloat(latlng.split(",")[1]); 4 return [lat, lng]; 5 }
43 function get_coordinates(lat_lng) { 44 if(lat_lng == 0) { 45 return customized_data[customized_data_idx]["Coordinates"][0]; 46 } 47 else { 48 return customized_data[customized_data_idx]["Coordinates"][1]; 49 } 50 51 }
387 function getStartGeoLocator(position) { 388 var sCoords = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); 389 var geocoder = new google.maps.Geocoder(); 390 geocoder.geocode({'latLng': sCoords}, function(results, status) { 391 if (status == google.maps.GeocoderStatus.OK) { 392 $('#startbox').val(results[0].formatted_address.replace(/, CA, USA/g, "")); 393 } 394 $('.geolocationwaiting').fadeOut(); 395 }); 396 }
94 toGoogleMaps() { 95 return "http://maps.google.com/?ll=" + this.LatitudeRaw + "," + this.LongitudeRaw; 96 }
434 function geocodePositionOSM(latLon, address, countrycodes, updateMap, callback) { 435 data = {format: 'json', addressdetails: 1, limit: 1, 'accept-language': geodir_all_js_msg.mapLanguage}; 436 437 if (address) { 438 type = 'search'; 439 data.q = address; 440 441 if (countrycodes) { 442 data.countrycodes = countrycodes.toLowerCase(); 443 } 444 } else if(latLon && typeof latLon === 'object') { 445 type = 'reverse'; 446 data.lat = latLon.lat; 447 data.lon = latLon.lng; 448 } else { 449 return; 450 } 451 452 jQuery.ajax({ 453 url: 'https://nominatim.openstreetmap.org/' + type, 454 dataType: "json", 455 data: data, 456 success: function(data, textStatus, jqXHR) { 457 if (type == 'search' && data.length) { 458 data = data[0]; 459 } 460 data = gd_osm_parse_item(data); 461 462 if (typeof callback === 'function') { 463 callback(data); 464 } else { 465 geocodeResponseOSM(data, updateMap); 466 } 467 }, 468 error: function(jqXHR, textStatus, errorThrown) { 469 console.log(errorThrown); 470 }, 471 complete: function(jqXHR, textStatus) { 472 } 473 }); 474 }
107 function geocodeAddress( address ) { 108 109 var geocoding_ok; 110 geocoder.geocode( { 'address': address}, function(results, status) { 111 112 if (status == google.maps.GeocoderStatus.OK) 113 { 114 map.panTo(results[0].geometry.location); 115 map.setZoom(16); 116 marker.setPosition(results[0].geometry.location); 117 $('#biopen_fournisseurbundle_provider_latlng_latitude').val(marker.getPosition().lat()); 118 $('#biopen_fournisseurbundle_provider_latlng_longitude').val(marker.getPosition().lng()); 119 120 geocoding_ok = true; 121 } 122 else 123 { 124 geocoding_ok = false; 125 } 126 }); 127 return geocoding_ok; 128 }