-
-
Save demirhancosku/efbe4e4c70fd819987149dd630178984 to your computer and use it in GitHub Desktop.
Mapjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Observable = require('FuseJS/Observable'); | |
var GeoLocation = require('FuseJS/GeoLocation'); | |
var Timer = require("FuseJS/Timer"); | |
var Api = require("App/Bundles/Api"); | |
var Util = require("App/Bundles/Util"); | |
var Timer = require("FuseJS/Timer"); | |
/* | |
* MODELS | |
*/ | |
var Marker = require("App/Models/Marker"); | |
var BottomFrame = require("App/Models/BottomFrame"); | |
/* | |
* HTTP REQUEST GELECEK | |
*/ | |
var markersRequest = function(lat,lon){ | |
Api.api( | |
{lat:lat,lon:lon}, | |
'/', | |
'GET', | |
function(error){ | |
console.log(JSON.stringify(error)); | |
console.log('MAP index Error'); | |
}, | |
function(result){ | |
for (i in result.data.vendors) { | |
var marker = new Marker.create(result.data.vendors[i]); | |
Marker.add(marker); | |
} | |
}); | |
} | |
var getMarkers = function(){ | |
Marker.clear(); | |
markersRequest(Util.location.value.latitude,Util.location.value.longitude); | |
} | |
var latMap = Observable(Util.location.value.latitude); | |
var lonMap = Observable(Util.location.value.longitude); | |
/* | |
* Mapview Refresh With Scroll listener will be active after 3 second | |
*/ | |
Timer.create(function() { | |
latMap.onValueChanged(module, function(item) { | |
markersRequest(latMap.value,lonMap.value); | |
}); | |
}, 3000, false); | |
module.exports = { | |
getMarkers:getMarkers, | |
latMap:latMap, | |
lonMap:lonMap, | |
markers:Marker.list, | |
onMarkerTappedIOS : function(args) { | |
var all = args.data.markers._values; | |
var selected = false; | |
for(i in all){ | |
if(all[i].label === args.label){ | |
selected = all[i]; | |
} | |
} | |
if(selected){ | |
//console.log(JSON.stringify(selected)); | |
BottomFrame.open(selected); | |
}else{ | |
BottomFrame.close(); | |
} | |
}, | |
hideMarkerIOS : function(){ | |
BottomFrame.close(); | |
}, | |
current: BottomFrame.current, | |
showResult:BottomFrame.isOpen | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment