Commit 58e0e7e3 authored by Deployer's avatar Deployer

Added new nearby API

parent f3929ca8
......@@ -20,8 +20,8 @@ This is CedarMaps Javascript API. It's simply a wrapper for [Mapbox Javascript A
Recommended usage is via the CedarMaps CDN:
```html
<script src='http://api.cedarmaps.com/cedarmaps.js/v1.4.2/cedarmaps.js'></script>
<link href='http://api.cedarmaps.com/cedarmaps.js/v1.4.2/cedarmaps.css' rel='stylesheet' />
<script src='http://api.cedarmaps.com/cedarmaps.js/v1.5.0/cedarmaps.js'></script>
<link href='http://api.cedarmaps.com/cedarmaps.js/v1.5.0/cedarmaps.css' rel='stylesheet' />
```
The `cedarmaps.js` file includes the Leaflet library. Alternatively, you can use `cedarmaps.standalone.js`, which does not include Leaflet (you will have to provide it yourself).
......
......@@ -5,9 +5,9 @@
<meta charset=utf-8 />
<title>CedarMaps - Sample Geocoder Control</title>
<script src='../dist/v1.4.2/cedarmaps.js'></script>
<script src='../dist/v1.5.0/cedarmaps.js'></script>
<script src='../access-token.js'></script>
<link href='../dist/v1.4.2/cedarmaps.css' rel='stylesheet' />
<link href='../dist/v1.5.0/cedarmaps.css' rel='stylesheet' />
<link href='css/styles.css' rel='stylesheet' />
......
......@@ -5,9 +5,9 @@
<meta charset=utf-8 />
<title>CedarMaps - Simple Map Load</title>
<script src='../dist/v1.4.2/cedarmaps.uncompressed.js'></script>
<script src='../dist/v1.5.0/cedarmaps.uncompressed.js'></script>
<script src='../access-token.js'></script>
<link href='../dist/v1.4.2/cedarmaps.css' rel='stylesheet' />
<link href='../dist/v1.5.0/cedarmaps.css' rel='stylesheet' />
<style>
body {
......
......@@ -5,9 +5,9 @@
<meta charset=utf-8 />
<title>CedarMaps - Simple Map Load</title>
<script src='../dist/v1.4.2/cedarmaps.uncompressed.js'></script>
<script src='../dist/v1.5.0/cedarmaps.uncompressed.js'></script>
<script src='../access-token.js'></script>
<link href='../dist/v1.4.2/cedarmaps.css' rel='stylesheet' />
<link href='../dist/v1.5.0/cedarmaps.css' rel='stylesheet' />
<style>
body {
......@@ -33,18 +33,17 @@
throw new Error('You need to get an access token to be able to use cedarmaps SDK. ' +
'Send us an email to <info@cedar.ir>');
}
L.cedarmaps.nearby('map', [35.737334, 51.355215], {
var nb = L.cedarmaps.nearby('map', [35.737334, 51.355215], {
categories: ['bus', 'park', 'shopping', 'hospital', 'school'],
searchDistance: 5,
popupContent: '<h2>html is allowed here</h2>',
defaultZoom: 20,
callback: function(map, center_marker, pois) {
setTimeout(function() {
center_marker.setLatLng({lat: 35.738934, lon: 51.356315})
map.setView({lat: 35.738934, lon: 51.356315})
}, 10000)
}
});
defaultZoom: 20
});
setTimeout(function() {
nb.updateCategories(['bus', 'park'])
nb.centerMarker.setLatLng({lat: 35.738934, lon: 51.356315})
nb.map.setView({lat: 35.738934, lon: 51.356315})
}, 5000)
</script>
</body>
......
......@@ -5,9 +5,9 @@
<meta charset=utf-8 />
<title>CedarMaps - Reverse Geocoding Sample</title>
<script src='../dist/v1.4.2/cedarmaps.js'></script>
<script src='../dist/v1.5.0/cedarmaps.js'></script>
<script src='../access-token.js'></script>
<link href='../dist/v1.4.2/cedarmaps.css' rel='stylesheet' />
<link href='../dist/v1.5.0/cedarmaps.css' rel='stylesheet' />
<style>
body {
......
......@@ -2,7 +2,7 @@
"author": "CedarStudios",
"name": "cedarmaps.js",
"description": "CedarMaps javascript API built on top of mapbox.js",
"version": "1.4.2",
"version": "1.5.0",
"homepage": "http://www.cedarmaps.com/",
"repository": {
"type": "git",
......
......@@ -13,8 +13,7 @@ module.exports = function (container, center, options) {
seachDistance: int,
popupContent: string,
noPoiLink: boolean,
lockScroll: boolean,
callback: fn(map, center_marker)
lockScroll: boolean,
}
*/
var stringHelpers = {
......@@ -259,10 +258,7 @@ module.exports = function (container, center, options) {
}).on('popupopen', function (e) {
e.popup.update();
});
}
if (options.callback) {
options.callback(map, centerMarker);
}
}
L.Control.CategoryToggle = L.Control.extend({
onAdd: function (map) {
var divControlContainer = L.DomUtil.create('div');
......@@ -325,9 +321,10 @@ module.exports = function (container, center, options) {
L.control.categoryToggle = function (opts) {
return new L.Control.CategoryToggle(opts);
}
L.control.categoryToggle({
var ctrl = L.control.categoryToggle({
position: 'topright'
}).addTo(map);
})
ctrl.addTo(map)
window.routing = function (el) {
if (el && el.getAttribute('data-from') && el.getAttribute('data-to')) {
corslite('https://api.cedarmaps.com/v1/direction/cedarmaps.driving/' + el.getAttribute('data-from') + ';' + el.getAttribute('data-to') + '?access_token=' + L.cedarmaps.accessToken, function (err, result) {
......@@ -374,4 +371,18 @@ module.exports = function (container, center, options) {
});
}
}
return {
updateCategories: function(categories) {
options.categories = categories
getPois(centerMarker.getLatLng())
map.removeControl(ctrl)
ctrl = L.control.categoryToggle({
position: 'topright'
})
ctrl.addTo(map)
},
map: map,
centerMarker: centerMarker
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment