LngLat
AMap.LngLat
Construct a geographic coordinate object to describe a point location on the map
new AMap.LngLat(lng: Number, lat: Number, noWrap: Boolean)Parameter
Demo
var lnglat = new AMap.LngLat(77.193045, 28.59086);Method
equals(another)
Determine if the latitude and longitude coordinates are equal to another set of latitude and longitude coordinates
Parameter:another(LngLat) Another latitude and longitude coordinate
return value:(Boolean) Is it equal
Demo:
lnglat.equals(new AMap.LngLat(77.182402, 28.588147));add(another, noWrap)
Add to another latitude and longitude
Parameter:
another(LngLat):Another latitude and longitude coordinate
noWrap(boolean): Whether to adjust the longitude value of the sum to the [-180, 180] interval, the default is false, when it is false the sum [190,30] will be automatically corrected to [-170,30], when it is true it will not be automatically corrected, and can be used for cross-date overlay drawing
return value:(LngLat) The result of adding two latitude and longitude coordinates
Demo:
lnglat.add(new AMap.LngLat(77.182402, 28.588147));subtract(another, noWrap)
Subtract another latitude and longitude
Parameter:
another(LngLat):Another latitude and longitude coordinate
noWrap(boolean):Whether to adjust the longitude value of the sum to the range of [-180,180], default is false, if false, the sum [190,30] will be automatically adjusted to [-170,30], if true, it will not be automatically adjusted and can be used for drawing overlays across date boundaries
return value:(LngLat) The result of subtracting two latitude and longitude coordinates
Demo:
lnglat.subtract(new AMap.LngLat(77.182402, 28.588147));offset(E, N)
Obtain the coordinate position after moving E meters east and N meters north from the current latitude and longitude position
Parameter:
E(Number):Movement in the longitude direction, with east as positive
N(Number):Movement in the latitude direction, with north as positive
return value:(LngLat) New latitude and longitude after moving
Demo:
lnglat.offset(10,10);toString()
LngLat object returned as a string
return value:(String) Format such as 'lng value, lat value' string
Demo:
lnglat.toString();toArray()
LngLat object returned as an array
return value:(String) Format such as: [lng value, lat value] array
Demo:
lnglat.toArray();distance(lnglat)
Calculate the distance between the current latitude and longitude and another latitude and longitude or the path composed of the latitude and longitude array
Parameter:lnglat(LngLat|[number, number]) Latitude and longitude or array of latitude and longitude to be calculated
return value:(number) Distance value in meters
Demo:
lnglat.distance(new AMap.LngLat(77.182402, 28.588147));