0.0.5 • Published 4 years ago

fhmap v0.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

fhmap

fhmap主要是用来使项目中地图功能的兼容性和扩展性更强,代码更容易维护,同时使切换地图的开发工作任务更少,成本更低

安装

npm install fhmap --save  

使用

//整个引入
import fhmap from 'fhmap'

//部分引入  
import {Map, Point} from 'fhmap'  

fhmap类概览

  • 核心类:

    Map

  • 基础类:

    PointPixelBoundsSize

  • 控件类:

    ControlNavigationControlGeolocationControlOverviewMapControlScaleControlCopyrightControlMapTypeControlPanoramaControl

  • 覆盖物类:

    OverlayMarkerIconInfoWindowLabelPolylineIconSequencePolygonCircleGroundOverlayPointCollectionHotspotSymbolCanvasLayer

  • 右键菜单类:

    ContextMenuMenuItem

  • 地图类型类:

    MapType

  • 地图图层类:

    TileLayerTrafficLayerCustomLayerPanoramaCoverageLayer

  • 服务类:

    LocalSearchTransitRouteWalkingRouteRidingRouteDrivingRouteGeocoderLocalCityGeolocationBusLineSearchAutocompleteBoundaryConvertor

  • 全景类:

    PanoramaPanoramaServicePanoramaLabel

  • 地图工具类:

    tools

  • 地图接口类:

    apis

  • 工具类:

    utils

###关于地图差异性解决的建议

由于每个地图厂商提供的地图类和方法名称可能不一致,建议在项目中新建一个allmap.js

 //allmap.js
 import {
  Map,
  //
  Point,
  Pixel,
  Bounds,
  Size,
  //
  Control,
  NavigationControl,
  GeolocationControl,
  OverviewMapControl,
  ScaleControl,
  CopyrightControl,
  MapTypeControl,
  PanoramaControl,
  //
  Overlay,
  Marker,
  Icon,
  InfoWindow,
  Label,
  Polyline,
  IconSequence,
  Polygon,
  Circle,
  GroundOverlay,
  PointCollection,
  Hotspot,
  Symbol,
  CanvasLayer,
  //
  ContextMenu,
  MenuItem,
  //
  MapType,
  //
  TileLayer,
  TrafficLayer,
  CustomLayer,
  PanoramaCoverageLayer,
  //
  LocalSearch,
  TransitRoute,
  WalkingRoute,
  RidingRoute,
  DrivingRoute,
  Geocoder,
  LocalCity,
  Geolocation,
  BusLineSearch,
  Autocomplete,
  Boundary,
  Convertor,
  //
  Panorama,
  PanoramaService,
  PanoramaLabel,
  //
  mapTools,
  //
  mapApis,
  //
  utils
} from 'fhmap' 

let mapProvider = getMapProvider();
//为避免和对象原有方法冲突,建议在方法名称前加下划线_区分
Pixel.prototype._equals = function(otherPixel) {
  if (mapProvider == "baidu") {
    return this.equals(otherPixel);
  } else {
    console.error("[Pixel]不支持该地图调用此方法");
  }
};

//...  

export {
  ...
}

业务代码中使用

import {Map, Point} from './allmap'
...

###地图类的支持性如下

百度凯立德图盟
(核心类)Map支持支持
(基础类)Point支持支持
(基础类)Pixel支持支持
(基础类)Bounds支持支持
(基础类)Size支持支持
(控件类)Control支持支持
(控件类)NavigationControl支持
(控件类)GeolocationControl支持
(控件类)OverviewMapControl支持
(控件类)ScaleControl支持
(控件类)CopyrightControl支持
(控件类)MapTypeControl支持
(控件类)PanoramaControl支持
(覆盖物类)Overlay支持
(覆盖物类)Marker支持
(覆盖物类)Icon支持
(覆盖物类)InfoWindow支持
(覆盖物类)Label支持
(覆盖物类)Polyline支持
(覆盖物类)IconSequence支持
(覆盖物类)Polygon支持
(覆盖物类)Circle支持
(覆盖物类)GroundOverlay支持
(覆盖物类)PointCollection支持
(覆盖物类)Hotspot支持
(覆盖物类)Symbol支持
(覆盖物类)CanvasLayer支持
(右键菜单类)ContextMenu支持
(右键菜单类)MenuItem支持
(地图类型类)MapType支持
(地图图层类)TileLayer支持
(地图图层类)TrafficLayer支持
(地图图层类)CustomLayer支持
(地图图层类)PanoramaCoverageLayer支持
(服务类)LocalSearch支持
(服务类)TransitRoute支持
(服务类)WalkingRoute支持
(服务类)RidingRoute支持
(服务类)DrivingRoute支持
(服务类)Geocoder支持
(服务类)LocalCity支持
(服务类)Geolocation支持
(服务类)BusLineSearch支持
(服务类)Autocomplete支持
(服务类)Boundary支持
(服务类)Convertor支持
(全景类)Panorama支持
(全景类)PanoramaService支持
(全景类)PanoramaLabel支持
0.0.5

4 years ago

0.0.3

4 years ago

0.0.0

4 years ago

0.0.1

4 years ago

1.0.0

4 years ago