Skip to content

Instantly share code, notes, and snippets.

@bguidolim
Created October 16, 2014 01:04
Show Gist options
  • Save bguidolim/6680d0cb06a0d99a9de7 to your computer and use it in GitHub Desktop.
Save bguidolim/6680d0cb06a0d99a9de7 to your computer and use it in GitHub Desktop.
var Mods = require('/ModulePaths');
var Map = require('com.guidolim.ticlusteredmapkit');
var mapview = Map.createView({
mapType:Map.NORMAL_TYPE,
width: Ti.UI.FILL,
height: Ti.UI.FILL
});
var data = Array();
AddAnnotations = function(){
var fileName = 'MOCK_DATA.json';
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, fileName);
Ti.API.info(file);
var preParseData = file.read();
var response = JSON.parse(preParseData);
for (var i=0; i < response.length; i++) {
var obj = response[i];
var annotation = Map.createAnnotation({
latitude: obj.latitude,
longitude: obj.longitude,
pincolor: Map.ANNOTATION_RED,
title: obj.address
});
data.push(annotation);
};
mapview.setAnnotations(data);
};
Window = function() {
var w = Ti.UI.createWindow();
AddAnnotations();
mapview.addEventListener("click", function(e){
if(e.clicksource == 'rightButton' || e.clicksource == 'rightPane') {
if(e.annotation.multiEvents){
var chooseW = require("chooseevent")(e.annotation.multiEvents);
Ti.App.tabgroup.activeTab.open(chooseW);
}else{
var profileW = require("eventprofile")(e.annotation.evt);
Ti.App.tabgroup.activeTab.open(profileW);
}
}
});
w.add(mapview);
return w;
};
module.exports = Window;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment