Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions source/javascripts/meetups.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
mapOptions.provider.zoomControlOptions = google.maps.ZoomControlStyle.SMALL;

var markerLocations = [];
var activeMeetups = $('.meetups.list .active');
var meetupList = $('.meetups.list a');

var generateMarkerData = function(element) {

Expand Down Expand Up @@ -63,14 +63,35 @@
});
};

function success(pos) {
var crd = pos.coords;
var latlng = new google.maps.LatLng(crd.latitude, crd.longitude);
function defaultLocation(){
var latlng = new google.maps.LatLng(3, -13);

handler.buildMap(mapOptions, function() {
handler.map.centerOn(latlng);
handler.getMap().setZoom(2);
});
}
geoLocation = navigator.geolocation.getCurrentPosition(success);

locations.forEach( generateMarkerData );
function setZoomBasedOnLatitudePosition(latitudePosition){
if(latitudePosition != 3){
handler.getMap().setZoom(8);
}else{
handler.getMap().setZoom(2);
}
}

function success(pos) {
var crd = pos.coords;
var latlng = new google.maps.LatLng(crd.latitude, crd.longitude);
handler.map.centerOn(latlng);
setZoomBasedOnLatitudePosition(handler.getMap().getCenter().k);

}

defaultLocation();
navigator.geolocation.getCurrentPosition(success);

locations.forEach(generateMarkerData);

handler.buildMap(mapOptions, function() {
drawMap();
Expand All @@ -83,7 +104,7 @@
var currentMarker = $('#'+markerId);

currentMarker.on('click', function(e){
activeMeetups.removeClass('active');
meetupList.removeClass('active');
$(this).addClass("active");
e.preventDefault();
handler.getMap().setZoom(14);
Expand All @@ -97,8 +118,9 @@
});

google.maps.event.addListener(json.marker.getServiceObject(), 'click', function(){
activeMeetups.removeClass('active');
meetupList.removeClass('active');
currentMarker.addClass("active");
handler.getMap().setZoom(14);
});
});
}
Expand All @@ -113,7 +135,8 @@
bindLiToMarker(markerLocations);

handler.bounds.extendWith(markers);
handler.getMap().setZoom(8);

setZoomBasedOnLatitudePosition(handler.getMap().getCenter().k);
}

function zoomToPosition(position) {
Expand Down