{"id":416,"date":"2018-11-01T14:22:15","date_gmt":"2018-11-01T13:22:15","guid":{"rendered":"https:\/\/numa-bord.com\/miniblog\/?p=416"},"modified":"2018-11-01T14:26:09","modified_gmt":"2018-11-01T13:26:09","slug":"mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps","status":"publish","type":"post","link":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/","title":{"rendered":"MapBox : Utiliser le \u00ab\u00a0map matching\u00a0\u00bb pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS"},"content":{"rendered":"<p>Nous allons voir dans cet article comment utiliser l&rsquo;API <a href=\"https:\/\/www.mapbox.com\/mapbox-gl-js\/example\/simple-map\/\" target=\"_blank\" rel=\"noopener\">MapBox<\/a> pour faire diff\u00e9rentes choses :<br \/>\n&#8211; Tracer un trajet \u00e0 partir de points GPS<br \/>\n&#8211; Tracer un itin\u00e9raire routier \u00e0 partir de ces points GPS<br \/>\n&#8211; Afficher des points cliquables sur la carte<br \/>\n&#8211; Recentrer la carte autour de ces trac\u00e9s\/points<\/p>\n<p>Le r\u00e9sultat que l&rsquo;on va obtenir est <a href=\"http:\/\/numa-bord.com\/labo\/mapbox\/\">visible ici<\/a><\/p>\n<p>Pour commencer il vous faut un \u00ab\u00a0token\u00a0\u00bb d\u2019acc\u00e8s \u00e0 l&rsquo;API que vous trouverez dans votre compte MapBox.<\/p>\n<p>Commen\u00e7ons par inclure les fichiers css et js n\u00e9cessaires \u00e0 l&rsquo;utilisation de l&rsquo;API. Dans la balise \u00ab\u00a0head\u00a0\u00bb de notre page :<\/p>\n<div class=\"codecolorer-container html4strict default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"html4strict codecolorer\"><span class=\"sc2\">&lt;<a href=\"http:\/\/december.com\/html\/4\/element\/script.html\"><span class=\"kw2\">script<\/span><\/a> <span class=\"kw3\">src<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">'https:\/\/api.tiles.mapbox.com\/mapbox-gl-js\/v0.50.0\/mapbox-gl.js'<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><a href=\"http:\/\/december.com\/html\/4\/element\/script.html\"><span class=\"kw2\">script<\/span><\/a>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<a href=\"http:\/\/december.com\/html\/4\/element\/link.html\"><span class=\"kw2\">link<\/span><\/a> <span class=\"kw3\">href<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">'https:\/\/api.tiles.mapbox.com\/mapbox-gl-js\/v0.50.0\/mapbox-gl.css'<\/span> <span class=\"kw3\">rel<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">'stylesheet'<\/span> <span class=\"sy0\">\/<\/span>&gt;<\/span><\/div><\/div>\n<p>Le html minimum pour afficher la carte dans le \u00ab\u00a0body\u00a0\u00bb de la page : c&rsquo;est un div avec un identifiant (ici \u00ab\u00a0map\u00a0\u00bb) ainsi qu&rsquo;une largeur et une hauteur :<\/p>\n<div class=\"codecolorer-container html4strict default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"html4strict codecolorer\">&lt;<a href=\"http:\/\/december.com\/html\/4\/element\/div.html\"><span class=\"kw2\">div<\/span><\/a> <span class=\"kw3\">id<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;map&quot;<\/span> <span class=\"kw3\">style<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;width: 100%; height: 400px;&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><a href=\"http:\/\/december.com\/html\/4\/element\/div.html\"><span class=\"kw2\">div<\/span><\/a>&gt;<\/div><\/div>\n<p>Tout est pr\u00eat, on peux attaquer le code javascript. Nous partons ici du principe que nous avons une liste de coordonn\u00e9es GPS sur lesquelles on veux travailler, voici celles de mon exemple :<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"co1\">\/\/la liste de nos points GPS, attention dans l'ordre [LONGITUDE, LATITUDE] (et non l'inverse)<\/span><br \/>\n<span class=\"kw1\">var<\/span> coords <span class=\"sy0\">=<\/span> <span class=\"br0\">&#91;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#91;<\/span><span class=\"nu0\">4.141553499740439<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">44.052572457451014<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#91;<\/span><span class=\"nu0\">4.143273931900012<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">44.05242402365157<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#91;<\/span><span class=\"nu0\">4.14427862409957<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">44.05275366184478<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#91;<\/span><span class=\"nu0\">4.145185210746604<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">44.05318932120335<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#91;<\/span><span class=\"nu0\">4.143211104911643<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">44.053065948966925<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#91;<\/span><span class=\"nu0\">4.141692974609214<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">44.05368666292508<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#91;<\/span><span class=\"nu0\">4.142165043395835<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">44.05420327703502<\/span><span class=\"br0\">&#93;<\/span><br \/>\n<span class=\"br0\">&#93;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>On initialise notre map sur le div #map, et au chargement on appelle nos diff\u00e9rentes fonctions qui effectueront les traitements voulus (fonctions que l&rsquo;on va cr\u00e9\u00e9es une par une juste apr\u00e8s)<br \/>\nLes 4 fonctions sont ind\u00e9pendantes, vous pouvez bien sur appeler uniquement celle qui vous int\u00e9resse.<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"co1\">\/\/token mapBox<\/span><br \/>\n<span class=\"kw1\">var<\/span> accessToken <span class=\"sy0\">=<\/span> <span class=\"st0\">'VOTRE-TOKEN-MAPBOX'<\/span><span class=\"sy0\">;<\/span><br \/>\nmapboxgl.<span class=\"me1\">accessToken<\/span> <span class=\"sy0\">=<\/span> accessToken<span class=\"sy0\">;<\/span><br \/>\n<span class=\"co1\">\/\/on initialise notre map sur le div #map<\/span><br \/>\n<span class=\"kw1\">var<\/span> map <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> mapboxgl.<span class=\"me1\">Map<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; container<span class=\"sy0\">:<\/span> <span class=\"st0\">'map'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; style<span class=\"sy0\">:<\/span> <span class=\"st0\">'mapbox:\/\/styles\/mapbox\/streets-v10'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; center<span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><span class=\"nu0\">4.141056<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">44.050022399999996<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span> <span class=\"co1\">\/\/un centre initial [longitude, latitude] (facultatif)<\/span><br \/>\n&nbsp; &nbsp; zoom<span class=\"sy0\">:<\/span> <span class=\"nu0\">13<\/span> <span class=\"co1\">\/\/un zoom initial (facultatif)<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"co1\">\/\/au chargement de la map<\/span><br \/>\nmap.<span class=\"me1\">on<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'load'<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/on recadre la carte en fonction de nos diff\u00e9rents points GPS<\/span><br \/>\n&nbsp; &nbsp; fitMap<span class=\"br0\">&#40;<\/span>map<span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/on affiche le trac\u00e9 reliant nos diff\u00e9rents points GPS<\/span><br \/>\n&nbsp; &nbsp; displayJourney<span class=\"br0\">&#40;<\/span>map<span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/on affiche l'itin\u00e9raire routier correspondant \u00e0 nos points GPS<\/span><br \/>\n&nbsp; &nbsp; displayJourneyReshaped<span class=\"br0\">&#40;<\/span>map<span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/on affiche des marqueurs \u00e0 la position de nos points GPS, indiquant leur num\u00e9ros et recentrant la carte sur eux au clic.<\/span><br \/>\n&nbsp; &nbsp; placeMarkers<span class=\"br0\">&#40;<\/span>map<span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>Pour que cela fonctionne il nous faut bien sur cr\u00e9er les fonctions correspondantes. On attaque avec la premi\u00e8re \u00ab\u00a0fitMap\u00a0\u00bb qui va permettre de cadrer la carte afin que toutes les coordonn\u00e9es qu&rsquo;on lui fournit soit visible :<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">function<\/span> fitMap<span class=\"br0\">&#40;<\/span>map<span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">var<\/span> bounds <span class=\"sy0\">=<\/span> coords.<span class=\"me1\">reduce<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>bounds<span class=\"sy0\">,<\/span> coord<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">return<\/span> bounds.<span class=\"me1\">extend<\/span><span class=\"br0\">&#40;<\/span>coord<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">new<\/span> mapboxgl.<span class=\"me1\">LngLatBounds<\/span><span class=\"br0\">&#40;<\/span>coords<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; map.<span class=\"me1\">fitBounds<\/span><span class=\"br0\">&#40;<\/span>bounds<span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; padding<span class=\"sy0\">:<\/span> <span class=\"nu0\">30<\/span> <span class=\"co1\">\/\/marge autour des points<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>On passe \u00e0 \u00ab\u00a0displayJourney\u00a0\u00bb qui trace une ligne droite entre chacun des points donn\u00e9s :<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">function<\/span> displayJourney<span class=\"br0\">&#40;<\/span>map<span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; map.<span class=\"me1\">addLayer<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;id&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;journey&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"co1\">\/\/identifiant unique de l'objet<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;type&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;line&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;source&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;type&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;geojson&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;data&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;type&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;Feature&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;properties&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;geometry&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;type&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;LineString&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;coordinates&quot;<\/span><span class=\"sy0\">:<\/span> coords<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;paint&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;line-color&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#888&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"co1\">\/\/couleur de la ligne<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">&quot;line-width&quot;<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">2<\/span> <span class=\"co1\">\/\/epaisseur de la ligne<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>C&rsquo;est d\u00e9j\u00e0 pas mal, mais on veux maintenant \u00e0 la place de ces lignes droites, d\u00e9finir le trajet \u00ab\u00a0r\u00e9el\u00a0\u00bb utilisable par un automobiliste (ou un cycliste \/ marcheur selon les param\u00e8tres) sur les chemins connus. Attention il vous faut moins de 100 points pour que cela fonctionne. Attention aussi, l&rsquo;utilisation de cette fonctionnalit\u00e9 est limit\u00e9 a 1000 appel par MapBox avant de devenir payant. Il peut donc \u00eatre int\u00e9ressant de stoker le r\u00e9sultat si on doit l&rsquo;afficher \u00e0 plusieurs reprise.<br \/>\nVoici la fonction \u00ab\u00a0displayJourneyReshaped\u00a0\u00bb qui lance un appel ajax \u00e0 l&rsquo;API Map Matching de MapBox pour calculer l&rsquo;itin\u00e9raire :<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">function<\/span> displayJourneyReshaped<span class=\"br0\">&#40;<\/span>map<span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/on transforme nos coordon\u00e9es en string pour l'appel de l'API<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">var<\/span> coordsString <span class=\"sy0\">=<\/span> coords.<span class=\"me1\">join<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">';'<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/choix du type d'itin\u00e9raire que l'on souhaite calculer (par exemple avec &quot;walking&quot; on ne fera pas le tour d'un rond point, avec &quot;driving&quot; si. <\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">var<\/span> typeRoute <span class=\"sy0\">=<\/span> <span class=\"st0\">'driving'<\/span><span class=\"sy0\">;<\/span> <span class=\"co1\">\/\/cycling, walking, driving-traffic<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">var<\/span> directionsRequest <span class=\"sy0\">=<\/span> <span class=\"st0\">'https:\/\/api.mapbox.com\/matching\/v5\/mapbox\/'<\/span><span class=\"sy0\">+<\/span>typeRoute<span class=\"sy0\">+<\/span><span class=\"st0\">'\/'<\/span> <span class=\"sy0\">+<\/span> coordsString <span class=\"sy0\">+<\/span> <span class=\"st0\">'?geometries=geojson&amp;access_token='<\/span> <span class=\"sy0\">+<\/span> accessToken<span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">var<\/span> xhr <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> XMLHttpRequest<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; xhr.<span class=\"me1\">open<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'GET'<\/span><span class=\"sy0\">,<\/span> directionsRequest<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; xhr.<span class=\"me1\">onload<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>xhr.<span class=\"me1\">status<\/span> <span class=\"sy0\">===<\/span> <span class=\"nu0\">200<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">var<\/span> response <span class=\"sy0\">=<\/span> JSON.<span class=\"me1\">parse<\/span><span class=\"br0\">&#40;<\/span>xhr.<span class=\"me1\">responseText<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/on r\u00e9cup\u00e8re la donn\u00e9es calcul\u00e9 qui nous permettra d'afficher l'itin\u00e9raire<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">var<\/span> route <span class=\"sy0\">=<\/span> response.<span class=\"me1\">matchings<\/span><span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span>.<span class=\"me1\">geometry<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/add layer<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; map.<span class=\"me1\">addLayer<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span class=\"sy0\">:<\/span> <span class=\"st0\">'journeyReshaped'<\/span><span class=\"sy0\">,<\/span> <span class=\"co1\">\/\/identifiant unique de l'objet<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type<span class=\"sy0\">:<\/span> <span class=\"st0\">'line'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type<span class=\"sy0\">:<\/span> <span class=\"st0\">'geojson'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type<span class=\"sy0\">:<\/span> <span class=\"st0\">'Feature'<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; geometry<span class=\"sy0\">:<\/span> route <span class=\"co1\">\/\/utilisation de l'itin\u00e9raire<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; paint<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">'line-color'<\/span><span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;#3399ff&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"co1\">\/\/couleur de la ligne<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">'line-width'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">4<\/span><span class=\"sy0\">,<\/span> <span class=\"co1\">\/\/epaisseur de la ligne<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"st0\">'line-opacity'<\/span><span class=\"sy0\">:<\/span> <span class=\"nu0\">0.7<\/span> <span class=\"co1\">\/\/opacit\u00e9 de la ligne<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span> <span class=\"kw1\">else<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/en cas d'erreur ajax<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span class=\"me1\">log<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'Request failed. &nbsp;Returned status of '<\/span> <span class=\"sy0\">+<\/span> xhr.<span class=\"me1\">status<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; xhr.<span class=\"me1\">send<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>En bonus la fonction \u00ab\u00a0placeMarkers\u00a0\u00bb qui permet d&rsquo;afficher des points cliquable sur la carte. Pour cela on commence par ajouter un peu de style css \u00e0 notre page pour l&rsquo;affichage de nos marqueurs ayant la classe \u00ab\u00a0marker\u00a0\u00bb. A mettre donc dans le style de votre page ou votre fichier css :<\/p>\n<div class=\"codecolorer-container css default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"css codecolorer\"><span class=\"re1\">.marker<\/span> <span class=\"br0\">&#123;<\/span><span class=\"kw1\">background<\/span><span class=\"sy0\">:<\/span> <span class=\"re0\">#888<\/span><span class=\"sy0\">;<\/span><span class=\"kw1\">width<\/span><span class=\"sy0\">:<\/span> <span class=\"re3\">22px<\/span><span class=\"sy0\">;<\/span><span class=\"kw1\">height<\/span><span class=\"sy0\">:<\/span> <span class=\"re3\">22px<\/span><span class=\"sy0\">;<\/span><span class=\"kw1\">border-radius<\/span><span class=\"sy0\">:<\/span> <span class=\"re3\">50%<\/span><span class=\"sy0\">;<\/span><span class=\"kw1\">text-align<\/span><span class=\"sy0\">:<\/span> <span class=\"kw2\">center<\/span><span class=\"sy0\">;<\/span><span class=\"kw1\">color<\/span><span class=\"sy0\">:<\/span><span class=\"re0\">#fff<\/span><span class=\"sy0\">;<\/span><span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"re1\">.marker<\/span><span class=\"sy0\">:<\/span><span class=\"kw5\">hover<\/span><span class=\"br0\">&#123;<\/span><span class=\"kw1\">background<\/span><span class=\"sy0\">:<\/span> <span class=\"re0\">#ff0<\/span><span class=\"sy0\">;<\/span><span class=\"kw1\">color<\/span><span class=\"sy0\">:<\/span><span class=\"re0\">#000<\/span><span class=\"sy0\">;<\/span><span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>Et enfin la fonction d&rsquo;affichage et clic des diff\u00e9rents points :<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">function<\/span> placeMarkers<span class=\"br0\">&#40;<\/span>map<span class=\"sy0\">,<\/span> coords<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">var<\/span> markers <span class=\"sy0\">=<\/span> <span class=\"br0\">&#91;<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/pour chaque point GPS dans coords<\/span><br \/>\n&nbsp; &nbsp; coords.<span class=\"me1\">forEach<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>coord<span class=\"sy0\">,<\/span> index<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/creation d'un div avec la classe 'marker' pour l'affichage du marker<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">var<\/span> el <span class=\"sy0\">=<\/span> document.<span class=\"me1\">createElement<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'div'<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; el.<span class=\"me1\">className<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">'marker'<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; el.<span class=\"me1\">setAttribute<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'data-index'<\/span><span class=\"sy0\">,<\/span> index<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><span class=\"co1\">\/\/on stocke son num\u00e9ro pour l'utilisation au click<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/creer un \u00e9l\u00e9ment pour indiquer le num\u00e9ro du marquer dans celui-ci<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">var<\/span> content <span class=\"sy0\">=<\/span> document.<span class=\"me1\">createTextNode<\/span><span class=\"br0\">&#40;<\/span>index<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; el.<span class=\"me1\">appendChild<\/span><span class=\"br0\">&#40;<\/span>content<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/on ajoute les marquers sur notre carte<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; markers<span class=\"br0\">&#91;<\/span>index<span class=\"br0\">&#93;<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> mapboxgl.<span class=\"me1\">Marker<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span>element<span class=\"sy0\">:<\/span> el<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">setLngLat<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#91;<\/span>coord<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span> coord<span class=\"br0\">&#91;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">addTo<\/span><span class=\"br0\">&#40;<\/span>map<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/au clic sur chacun d'eux on recentre la carte sur sa position<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; el.<span class=\"me1\">addEventListener<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;click&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>e<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; map.<span class=\"me1\">flyTo<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span>center<span class=\"sy0\">:<\/span> markers<span class=\"br0\">&#91;<\/span>e.<span class=\"me1\">target<\/span>.<span class=\"me1\">dataset<\/span>.<span class=\"me1\">index<\/span><span class=\"br0\">&#93;<\/span>.<span class=\"me1\">getLngLat<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>Je pense que c&rsquo;est un bon d\u00e9but pour travailler avec MapBox, maintenant \u00e0 vous le tour !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nous allons voir dans cet article comment utiliser l&rsquo;API MapBox pour faire diff\u00e9rentes choses : &#8211; Tracer un trajet \u00e0 partir de points GPS &#8211; Tracer un itin\u00e9raire routier \u00e0 partir de ces points GPS &#8211; Afficher des points cliquables sur la carte &#8211; Recentrer la carte autour de ces trac\u00e9s\/points Le r\u00e9sultat que l&rsquo;on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,11,17],"tags":[],"class_list":["post-416","post","type-post","status-publish","format-standard","hentry","category-developpement","category-javascript","category-mapbox-api"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MapBox : Utiliser le &quot;map matching&quot; pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS - Pense b\u00eate d&#039;un d\u00e9veloppeur web<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MapBox : Utiliser le &quot;map matching&quot; pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS - Pense b\u00eate d&#039;un d\u00e9veloppeur web\" \/>\n<meta property=\"og:description\" content=\"Nous allons voir dans cet article comment utiliser l&rsquo;API MapBox pour faire diff\u00e9rentes choses : &#8211; Tracer un trajet \u00e0 partir de points GPS &#8211; Tracer un itin\u00e9raire routier \u00e0 partir de ces points GPS &#8211; Afficher des points cliquables sur la carte &#8211; Recentrer la carte autour de ces trac\u00e9s\/points Le r\u00e9sultat que l&rsquo;on [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/\" \/>\n<meta property=\"og:site_name\" content=\"Pense b\u00eate d&#039;un d\u00e9veloppeur web\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-01T13:22:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-11-01T13:26:09+00:00\" \/>\n<meta name=\"author\" content=\"Numa\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"Numa\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/\"},\"author\":{\"name\":\"Numa\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e\"},\"headline\":\"MapBox : Utiliser le \u00ab\u00a0map matching\u00a0\u00bb pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS\",\"datePublished\":\"2018-11-01T13:22:15+00:00\",\"dateModified\":\"2018-11-01T13:26:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/\"},\"wordCount\":1015,\"commentCount\":2,\"articleSection\":[\"D\u00e9veloppement\",\"Javascript\",\"MapBox API\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/\",\"url\":\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/\",\"name\":\"MapBox : Utiliser le \\\"map matching\\\" pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS - Pense b\u00eate d&#039;un d\u00e9veloppeur web\",\"isPartOf\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#website\"},\"datePublished\":\"2018-11-01T13:22:15+00:00\",\"dateModified\":\"2018-11-01T13:26:09+00:00\",\"author\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e\"},\"breadcrumb\":{\"@id\":\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/numa-bord.com\/miniblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MapBox : Utiliser le \u00ab\u00a0map matching\u00a0\u00bb pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#website\",\"url\":\"https:\/\/numa-bord.com\/miniblog\/\",\"name\":\"Pense b\u00eate d&#039;un d\u00e9veloppeur web\",\"description\":\"(php, javascript, Symfony, Wordpress....)\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/numa-bord.com\/miniblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e\",\"name\":\"Numa\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g\",\"caption\":\"Numa\"},\"url\":\"https:\/\/numa-bord.com\/miniblog\/author\/negonner\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MapBox : Utiliser le \"map matching\" pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS - Pense b\u00eate d&#039;un d\u00e9veloppeur web","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/","og_locale":"fr_FR","og_type":"article","og_title":"MapBox : Utiliser le \"map matching\" pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS - Pense b\u00eate d&#039;un d\u00e9veloppeur web","og_description":"Nous allons voir dans cet article comment utiliser l&rsquo;API MapBox pour faire diff\u00e9rentes choses : &#8211; Tracer un trajet \u00e0 partir de points GPS &#8211; Tracer un itin\u00e9raire routier \u00e0 partir de ces points GPS &#8211; Afficher des points cliquables sur la carte &#8211; Recentrer la carte autour de ces trac\u00e9s\/points Le r\u00e9sultat que l&rsquo;on [&hellip;]","og_url":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/","og_site_name":"Pense b\u00eate d&#039;un d\u00e9veloppeur web","article_published_time":"2018-11-01T13:22:15+00:00","article_modified_time":"2018-11-01T13:26:09+00:00","author":"Numa","twitter_card":"summary_large_image","twitter_misc":{"\u00c9crit par":"Numa","Dur\u00e9e de lecture estim\u00e9e":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/#article","isPartOf":{"@id":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/"},"author":{"name":"Numa","@id":"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e"},"headline":"MapBox : Utiliser le \u00ab\u00a0map matching\u00a0\u00bb pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS","datePublished":"2018-11-01T13:22:15+00:00","dateModified":"2018-11-01T13:26:09+00:00","mainEntityOfPage":{"@id":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/"},"wordCount":1015,"commentCount":2,"articleSection":["D\u00e9veloppement","Javascript","MapBox API"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/","url":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/","name":"MapBox : Utiliser le \"map matching\" pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS - Pense b\u00eate d&#039;un d\u00e9veloppeur web","isPartOf":{"@id":"https:\/\/numa-bord.com\/miniblog\/#website"},"datePublished":"2018-11-01T13:22:15+00:00","dateModified":"2018-11-01T13:26:09+00:00","author":{"@id":"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e"},"breadcrumb":{"@id":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/numa-bord.com\/miniblog\/mapbox-utiliser-le-map-matching-pour-tracer-un-itineraire-routier-a-partir-de-points-gps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/numa-bord.com\/miniblog\/"},{"@type":"ListItem","position":2,"name":"MapBox : Utiliser le \u00ab\u00a0map matching\u00a0\u00bb pour tracer un itin\u00e9raire routier \u00e0 partir de points GPS"}]},{"@type":"WebSite","@id":"https:\/\/numa-bord.com\/miniblog\/#website","url":"https:\/\/numa-bord.com\/miniblog\/","name":"Pense b\u00eate d&#039;un d\u00e9veloppeur web","description":"(php, javascript, Symfony, Wordpress....)","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/numa-bord.com\/miniblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Person","@id":"https:\/\/numa-bord.com\/miniblog\/#\/schema\/person\/f9d00acd1703f17e5a6895283eb46a7e","name":"Numa","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f21d1af4658a7106211915940584534c1e0b3eef3f12eb67a697686cad70b64a?s=96&d=mm&r=g","caption":"Numa"},"url":"https:\/\/numa-bord.com\/miniblog\/author\/negonner\/"}]}},"_links":{"self":[{"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/posts\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":9,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":428,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/posts\/416\/revisions\/428"}],"wp:attachment":[{"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/numa-bord.com\/miniblog\/wp-json\/wp\/v2\/tags?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}