latlng

Parse out a longitude and latitude from a value that is either a string or object.

  • latlng

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
latlng
101.0.010 years ago10 years agoMinified + gzip package size for latlng in KB

Readme

latlng

module.exports(value, options) ⏏

Parse out an object with lat and lng from a string. Or you can use this to normalize objects to lat long format.
You can pass in an options object which modifies how lat lng's are parsed.
Here are options you can pass in:
{
	delimiter: ',' // you can pass in a delimiter which is used to find a longitude and latitude
}

Params
  • value String | Object - A lat long value you'd like to convert to an object
    options Object - This is an options object which can be used to parse the lat long. See above

Returns: Object | Null - This function will turn an object which will contain the variables lat and lng
when parsing succeeds. If it fails null is passed back.  
Example
var val = require( 'latlng' )( '-54.23,34' );

console.log( rVal ); // { lat: -54.23, lng: 34 }