Giter Site home page Giter Site logo

leijianhua / leaflet.routing.amap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uinjack/leaflet.routing.amap

1.0 0.0 0.0 873 KB

Control for route search using AMap(高德地图) as a backend. Supports the Chinese BD09 and GCJ02 coordinate systems, colourful lines, and turn-by-turn popups.

License: MIT License

JavaScript 96.82% CSS 2.62% HTML 0.56%

leaflet.routing.amap's Introduction

Leaflet.Routing.Amap

Description

Control for route search using AMap(高德地图) as a backend. Supports the Chinese BD09 and GCJ02 coordinate systems, colourful lines, and turn-by-turn popups.

demo

Examples

Demo

demo

Getting Started

Install the dependencies:

npm install

Usage

 var route = new L.Routing(map,{
  		 transform: "WGS84",
        colorfulLine: true,
        isZoom: true
 });
 route.getRoute(L.Routing.BYWALK, [39.94185, 116.431549], [39.98974, 116.40683]);

Default conf is :

set this properties at Leaflet.Routing.Amap/src/L.Routing.Conf.js.

Initialize Options

option name default comment
transform "WGS84" In China have a diffrent situation,so use diffrent map you need get you projection transformed. this properties depend on you base map,if you base map is WGS84 ,you'v got get filling-in "WGS84",we support three options,is "WGS84","BD09" and "GCJ02",if you base map is another, just extend this method.
color "RGBA(245, 224, 128, 1.0)" Set route polyline color ,you can try to set "multi".will have a different impact.
isZoom true if you don't want to you map zoom to result when result callback,you could set "false"
isShowRoutePopup true routePopup is open or not
isShowQueryPopup true Query result popup is open or not.

Method

getRoute

Beacuse of this methon is async so when you use this method , we just could put the result layer fill in the map.none return.but you can use event listener to listen this function.and getPOI too.

	 
	getRoute(how, from, to);
	
option name describe
how has three options is "Bybus","Bywalk","Bycar"
from point format is like [lat,lng]
to point format is like [latlng]

getPOI

	 
	getPOI(keyword);
	
option name describe
keyword keyword in you search

properties

properties describe
routeLayer Result of route request
queryLayer Result of POI request
BYCAR This is static method, for "getRoute" how option
BYBUS This is static method, for "getRoute" how option
BYWALK This is static method, for "getRoute" how option

Event

You can listen event below that.

	 var route = new L.Routing(map);
	 route.on("MARKCLICK", function (e) {		
	    //handing 
     }, this)
	 
Event Name describe
MARKCLICK When POI be clicked
WALKROUTEBACK When walk route back
BUSROUTEBACK When bus route back
CARROUTEBACK When car route back

leaflet.routing.amap's People

Contributors

uinjack avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.