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 ...@@ -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: Recommended usage is via the CedarMaps CDN:
```html ```html
<script src='http://api.cedarmaps.com/cedarmaps.js/v1.4.2/cedarmaps.js'></script> <script src='http://api.cedarmaps.com/cedarmaps.js/v1.5.0/cedarmaps.js'></script>
<link href='http://api.cedarmaps.com/cedarmaps.js/v1.4.2/cedarmaps.css' rel='stylesheet' /> <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). 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 @@ ...@@ -5,9 +5,9 @@
<meta charset=utf-8 /> <meta charset=utf-8 />
<title>CedarMaps - Sample Geocoder Control</title> <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> <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' /> <link href='css/styles.css' rel='stylesheet' />
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<meta charset=utf-8 /> <meta charset=utf-8 />
<title>CedarMaps - Simple Map Load</title> <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> <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> <style>
body { body {
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<meta charset=utf-8 /> <meta charset=utf-8 />
<title>CedarMaps - Simple Map Load</title> <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> <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> <style>
body { body {
...@@ -33,18 +33,17 @@ ...@@ -33,18 +33,17 @@
throw new Error('You need to get an access token to be able to use cedarmaps SDK. ' + 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>'); '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'], categories: ['bus', 'park', 'shopping', 'hospital', 'school'],
searchDistance: 5, searchDistance: 5,
popupContent: '<h2>html is allowed here</h2>', popupContent: '<h2>html is allowed here</h2>',
defaultZoom: 20, 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)
}
}); });
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> </script>
</body> </body>
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<meta charset=utf-8 /> <meta charset=utf-8 />
<title>CedarMaps - Reverse Geocoding Sample</title> <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> <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> <style>
body { body {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"author": "CedarStudios", "author": "CedarStudios",
"name": "cedarmaps.js", "name": "cedarmaps.js",
"description": "CedarMaps javascript API built on top of mapbox.js", "description": "CedarMaps javascript API built on top of mapbox.js",
"version": "1.4.2", "version": "1.5.0",
"homepage": "http://www.cedarmaps.com/", "homepage": "http://www.cedarmaps.com/",
"repository": { "repository": {
"type": "git", "type": "git",
......
...@@ -14,7 +14,6 @@ module.exports = function (container, center, options) { ...@@ -14,7 +14,6 @@ module.exports = function (container, center, options) {
popupContent: string, popupContent: string,
noPoiLink: boolean, noPoiLink: boolean,
lockScroll: boolean, lockScroll: boolean,
callback: fn(map, center_marker)
} }
*/ */
var stringHelpers = { var stringHelpers = {
...@@ -260,9 +259,6 @@ module.exports = function (container, center, options) { ...@@ -260,9 +259,6 @@ module.exports = function (container, center, options) {
e.popup.update(); e.popup.update();
}); });
} }
if (options.callback) {
options.callback(map, centerMarker);
}
L.Control.CategoryToggle = L.Control.extend({ L.Control.CategoryToggle = L.Control.extend({
onAdd: function (map) { onAdd: function (map) {
var divControlContainer = L.DomUtil.create('div'); var divControlContainer = L.DomUtil.create('div');
...@@ -325,9 +321,10 @@ module.exports = function (container, center, options) { ...@@ -325,9 +321,10 @@ module.exports = function (container, center, options) {
L.control.categoryToggle = function (opts) { L.control.categoryToggle = function (opts) {
return new L.Control.CategoryToggle(opts); return new L.Control.CategoryToggle(opts);
} }
L.control.categoryToggle({ var ctrl = L.control.categoryToggle({
position: 'topright' position: 'topright'
}).addTo(map); })
ctrl.addTo(map)
window.routing = function (el) { window.routing = function (el) {
if (el && el.getAttribute('data-from') && el.getAttribute('data-to')) { 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) { 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) { ...@@ -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