Skip to content

Commit

Permalink
updated extensions description and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarcon committed Nov 21, 2012
1 parent f4209e7 commit 5ebd740
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
31 changes: 30 additions & 1 deletion EXTENSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,33 @@ When this extension is included a map is automatically initialized on a containe

This extension packaged together with the plugin enables *HTML developers* to insert a map in their pages without having to write a single line of JavaScript.


###routing extension

When this extension is include it is possible to add routes to the map by simply doing the following:

`$('.selector').jHERE('route', from, to, routeOptions);`

`from` and `to` can be objects of type

`{latitude: -43, longitude: 55}`

or an array

`[-43, 55]`

`routeOptions` is optional and can be an object of type

{
marker: {},
type: 'shortest', //can be shortest, fastest, fastestNow, directDrive, scenic
transportMode: 'car', //can be car, pedestrian, publicTransport, truck
options: '', //can be avoidTollroad, avoidMotorway, avoidBoatFerry,
//avoidRailFerry, avoidPublicTransport, avoidTunnel,
//avoidDirtRoad, avoidPark, preferHOVLane, avoidStairs
trafficMode: 'default', //can be enabled, disabled, default
width: 4, //width in px of the route drawn on the map
color: '#ff6347' //color of the route drawn on the map
}

`marker` is an object containing the same options used for
`$('.selector').jHERE('marker')`. Options apply to both start and destionation markers.
2 changes: 1 addition & 1 deletion src/extensions/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//}</code></pre>
//
//`marker` is an object containing the same options used for
//`$('.selector').jHERE('marker'). Options apply to both start and destionation markers.
//`$('.selector').jHERE('marker')`. Options apply to both start and destionation markers.
route = function(from, to, options){
var router, wp, done;
_ns = _ns || nokia.maps;
Expand Down
19 changes: 19 additions & 0 deletions src/jhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,25 @@

/*Open up prototype for extensions*/
$[plugin] = {};

//###Extend jHERE
//jHERE can be easily extended with additional features. Some example of
//extensions are located [here](https://github.com/mmarcon/jhere/blob/master/EXTENSIONS.md).
//An extension should be implemented within a self-invoking function.
//Add the function(s)
//that will be called via
//
//`$('.selector').jHERE('myextension', param1, param2);`
//
//as follows:
//
//<pre><code class="dark">$.jHERE.extend('myextension', function(param1, param2){
// //this is the plugin object
// //this.element is the DOM element
// //this.map is the JSLA map
//});</code></pre>
//
//A good example of extension is the [routing extension](https://github.com/mmarcon/jhere/blob/master/src/extensions/route.js).
$[plugin].extend = function(name, fn){
if (typeof name === 'string' && isFunction(fn)) {
H[name] = fn;
Expand Down

0 comments on commit 5ebd740

Please sign in to comment.