基础类 最后更新时间: 2021年01月22日
经纬度坐标
说明
指具有一定的经度和纬度的地理点。
示例
var latlng = Indoor.latLng(50.5, 30.5);
map.panTo([50, 30]);
map.panTo({lon: 30, lat: 50});
map.panTo({lat: 50, lng: 30});
map.panTo(Indoor.latLng(50, 30));
创建
Factory | Description |
---|---|
Indoor.latLng(<Number> latitude,<Number> longitude,<Number> altitude? ) | 创建经纬度坐标. |
属性
Property | Type | Description |
---|---|---|
lat | Number | 纬度. |
lng | Number | 经度. |
方法
Method | returns | Description |
---|---|---|
distanceTo( <LatLng> otherLatlng ) | Number | 返回两坐标点的距离 |
equals( <LatLng> otherLatlng ) | Boolean | 判断两坐标是否相等. |
toString() | String | 转换为字符串格式. |
经纬度范围
说明
表示地图上的矩形的地理区域。
示例
var southWest = Indoor.latLng(40.712, -74.227),
northEast = Indoor.latLng(40.774, -74.125),
bounds = Indoor.latLngBounds(southWest, northEast);
map.fitBounds([
[40.712, -74.227],
[40.774, -74.125]
]);
创建
Factory | Description |
---|---|
Indoor.latLngBounds(<LatLng> southWest, <LatLng> northEast) | 通过西南和东北角坐标创建一个范围. |
Indoor.latLngBounds(<LatLng[]> latlngs ) | 通过坐标数组创建一个范围. |
方法
Method | returns | Description |
---|---|---|
getWest() | Number | 获取西经. |
getSouth() | Number | 获取南纬. |
getEast() | Number | 获取东经. |
getNorth() | Number | 获取北纬. |
getCenter() | LatLng | 获取中心点. |
边界
简介
在地图上的一个矩形区域。
示例
var p1 = Indoor.point(10, 10),
p2 = Indoor.point(40, 60),
bounds = Indoor.bounds(p1, p2);
创建
Factory | Description |
---|---|
Indoor.bounds( <Point> topLeft, <Point> bottomRight ) | 输入左上角和右下角坐标创建边界. |
Indoor.bounds( <Point[]> points ) | 输入坐标点数组创建边界. |
属性
Property | Type | Description |
---|---|---|
min | Point | 矩形的左上角 |
max | Point | 矩形的右下角. |
方法
Method | returns | Description |
---|---|---|
getCenter() | Point | 获取中心点坐标. |
isValid() | Boolean | 判断是否初始化成功. |
getSize() | Point | 返回给定的范围的大小. |
像素点
简介
表示与x和y坐标中的像素的点。
示例
var point = Indoor.point(200, 300);
map.panBy([200, 300]);
map.panBy(Indoor.point(200, 300));
创建
Factory | Description |
---|---|
Indoor.point( <Number> x, <Number> y,<Boolean> round? ) | 创建一个Point对象与给定的x和y坐标,round参数 |
属性
Property | Type | Description |
---|---|---|
x | Number | x坐标. |
y | Number | y坐标. |
图标
简介
图标用于创建一个标注的属性。
示例
var myIcon = Indoor.icon({
iconUrl: 'my-icon.png',
iconRetinaUrl: 'my-icon@2x.png',
iconSize: [38, 95],
iconAnchor: [22, 94],
popupAnchor: [-3, -76],
shadowUrl: 'my-icon-shadow.png',
shadowRetinaUrl: 'my-icon-shadow@2x.png',
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
Indoor.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
Indoor.Icon.Default 扩展 Indoor.Icon.
创建
Factory | Description |
---|---|
Indoor.icon( <Icon options> options ) | 创建一个图标. |
选项
Option | Type | Description |
---|---|---|
iconUrl | String | 图片的URL. |
iconRetinaUrl | String | Retina视网膜屏的设备上显示的图片URL. |
iconSize | Point | 图标的大小. |
iconAnchor | Point | 此图标在地图上的锚定点相对于图标图像左上角的像素坐标. |
shadowUrl | String | 图标的阴影图像URL |
shadowRetinaUrl | String | Retina视网膜屏的设备上显示的阴影图片URL. |
shadowSize | Point | 阴影图像的大小. |
shadowAnchor | Point | 此阴影图像在地图上的锚定点相对于阴影图像左上角的像素坐标. |
popupAnchor | Point | 信息窗体的锚点. |
className | String | 设置图标和阴影的样式名称,默认为空. |
DivIcon
简介
使用HTML的DIV元素来创建图标。
示例
var myIcon = Indoor.divIcon({className: 'my-div-icon'});
// .my-div-icon styles 为样式名称
Indoor.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
创建
Factory | Description |
---|---|
Indoor.divIcon(<DivIcon options> options ) | 创建图标. |
选项
Option | Type | Description |
---|---|---|
iconSize | Point | 图标大小,也可以通过CSS来控制. |
iconAnchor | Point | 图标相对了图标的左上角锚点位置. |
className | String | 样式名称. |
html | String | 自定义的HTML内容,默认值为空. |