Linking the MapSearch 2.0 plugin to the RouteViewer 3.0 plugin and/or the PoiViewer 2.0 plugin
By default, the MapSearch plugin links back to the RouteYou website. However, when you use both the MapSearch and RouteViewer / PoiViewer plugins on your website, you will want to change this behaviour.
Step 1: MapSearch
In the MapSearch plugin, you need to change the URL to which routes and/or places of interest will link.
- Configure the MapSearch plugin to your liking. Consult the documentation to find out how.
- Add the parameters you need from the "Link parameters" section. You can structure your URL any way you like.
Your configuration object will now, for example, look like this:
RTY.MapSearch.load({ 'token': '<your RouteYou web service token>', 'language': '<your language>', ... 'route.view.link': 'https://www.mywebsite.com/routeview?route-id=%id%', 'poi.view.link': 'https://www.mywebsite.com/poiview?poi-id=%id%' });
Or with the iframe version:
<iframe src="//plugin.routeyou.com/mapsearch/basic/?token=<your RouteYou web service token>&language=<your language>&route.view.link=https%3A%2F%2Fwww.mywebsite.com%2Frouteview%3Froute-id%3D%25id%25&poi.view.link=https%3A%2F%2Fwww.mywebsite.com%2Fpoiview%3Fpoi-id%3D%25id%25" width="800" height="500" frameborder="0" allowfullscreen></iframe>
Step 2: RouteViewer / PoiViewer
For the RouteViewer and PoiViewer plugin, you need to extract the route / place of interest ID from the URL.
- Configure the RouteViewer / PoiViewer plugin to your liking. Consult the documentation to find out how.
- Set the params.route.id / params.poi.id parameter to the ID passed in the URL. You can do this any way you like, but always remember that the route / place of interest ID should be passed to the plugin as an integer, not a string (use JavaScript's parseInt or a server side equivalent as needed). If you want to do it client-side, the RouteViewer and PoiViewer plugins provide a convenience method to extract the ID from the URL,
RTY.Util.Uri.getQueryParameter
.
If you use this convenience method, your configuration object will now, for example, look like this:
RTY.RouteViewer.load({
'token': '<your RouteYou web service token>',
'language': '<your language>',
...
'params.route.id': parseInt(RTY.Util.Uri.getQueryParameter('route-id')
, 10)
});
RTY.PoiViewer.load({
'token': '<your RouteYou web service token>',
'language': '<your language>',
...
'params.poi.id': parseInt(RTY.Util.Uri.getQueryParameter('poi-id')
, 10)
});
Or with the iframe version:
<iframe src="//plugin.routeyou.com/routeviewer/basic/?token=<your RouteYou web service token>&language=<your language>&params.route.id=<route ID>" width="800" height="500" frameborder="0" allowfullscreen></iframe>
<iframe src="//plugin.routeyou.com/poiviewer/basic/?token=<your RouteYou web service token>&language=<your language>&params.poi.id=<POI ID>" width="800" height="500" frameborder="0" allowfullscreen></iframe>