Permalink
Browse files

Added geocode component

  • Loading branch information...
mmarcon committed Dec 1, 2012
1 parent 75e07a4 commit 15740333cdf3793e894ffd50327baaa03cfc7ea5
Showing with 43 additions and 15 deletions.
  1. +1 −1 dist/jhere.min.js
  2. +11 −9 src/examples/index.html
  3. +31 −5 src/jhere.js
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -275,16 +275,18 @@
</script>
<script type="text/javascript">
$(window).on('load', function(){
$('#map').jHERE({enable: ['behavior', 'zoombar', 'typeselector', 'positioning', 'contextmenu']});
$('#map').jHERE('type', 'smart').jHERE('marker', [52.49, 13.37], {text: '', textColor: '#fff', fill: '#004C9A',
click: function(e){
alert(JSON.stringify(e.geo));
}}).jHERE('marker', [52.49, 13.39], {text: '', textColor: '#fff', fill: '#004C9A',
click: function(e){
$(this).jHERE('bubble', [52.49, 13.39], {content: JSON.stringify(e.geo), closable: false});
}}).jHERE('heatmap', heatMapData, 'value');
$('#map').jHERE('kml', 'resources/berlin.kml', true);
$.jHERE.geocode('Berlin, Germany', function(center){
$('#map').jHERE({enable: ['behavior', 'zoombar', 'typeselector', 'positioning', 'contextmenu'], center: center});
$('#map').jHERE('type', 'smart').jHERE('marker', [52.49, 13.37], {text: '', textColor: '#fff', fill: '#004C9A',
click: function(e){
alert(JSON.stringify(e.geo));
}}).jHERE('marker', [52.49, 13.39], {text: '', textColor: '#fff', fill: '#004C9A',
click: function(e){
$(this).jHERE('bubble', [52.49, 13.39], {content: JSON.stringify(e.geo), closable: false});
}}).jHERE('heatmap', heatMapData, 'value');
$('#map').jHERE('kml', 'resources/berlin.kml');
});
});
</script>
</body>
</html>
View
@@ -50,7 +50,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var plugin = 'jHERE',
version = '0.2.0',
defaults, H, _ns, _JSLALoader,
_credentials, bind = $.proxy;
_credentials, bind = $.proxy, P;
defaults = {
appId: '_peU-uCkp-j8ovkzFGNU',
@@ -81,6 +81,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}
};
$[plugin] = P = {};
//### Make a map
//`$('.selector').jHERE(options);`
//
@@ -128,6 +131,32 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
H = jHERE.prototype;
//### Set default credentials
//`$.jHERE.defaultCredentials(appId, authToken);`
P.defaultCredentials = function(appId, authToken) {
defaults.appId = appId;
defaults.authToken = authToken;
};
/*@component=geocode*/
P.geocode = function(query, success, error) {
_JSLALoader.load().is.done(function(){
var searchCenter = new _ns.geo.Coordinate(0, 0),
searchManager = nokia.places.search.manager;
function geocodeCallback(data, status) {
if(status === 'OK') {
success(data.location && data.location.position);
}
}
searchManager.geoCode({
searchTerm: query,
onComplete: geocodeCallback
});
});
};
/*@endcomponent*/
H.init = function(){
var options = this.options;
_JSLALoader.load().is.done(bind(this.makemap, this));
@@ -492,9 +521,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return this;
};
/*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).
@@ -513,7 +539,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//});</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){
P.extend = function(name, fn){
if (typeof name === 'string' && isFunction(fn)) {
H[name] = fn;
}

0 comments on commit 1574033

Please sign in to comment.