im tryng to ad a zoom event on my map which transform my heatmap in marker. I found this code and tryinn to apply it on my map
var points = L.geoJson('1999to2022.geojson', {
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {});
} });
map.on('zoomend', function() { var zoomlevel = map.getZoom();
if (zoomlevel <6){
if (map.hasLayer(points)) {
map.removeLayer(points);
} else {
console.log("no point layer active");
}
}
if (zoomlevel >= 7){
if (map.hasLayer(points)){
console.log("layer already added");
} else {
map.addLayer(points);
}
} });
I was wondering what I could be doing wrong and if this was the easiest way to display my popup.
Thanks!
I have two JSSOR sliders working except the responsive part only works for one slider.
Even duplicating the responsive code does nothing. Anyone have any ideas?
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
var jssor_slider2 = new $JssorSlider$("slider2_container", options);
//responsive code begin
//you can remove responsive code if you don't want the slider scales while window resizes
function ScaleSlider() {
var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider1.$ScaleWidth(Math.max(Math.min(parentWidth, 800), 300));
else
window.setTimeout(ScaleSlider, 30);
}
ScaleSlider();
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
//responsive code end
});
</script>
For all the code the website is http://garyedwardrotter.com and the portions with the sliders are in the photography section. Just the first two are setup right now and I have used the same exact code/slider setup for both.
Any help is very appreciated, thank you.
Please replace
if (parentWidth)
jssor_slider1.$ScaleWidth(Math.max(Math.min(parentWidth, 800), 300));
with
if (parentWidth) {
jssor_slider1.$ScaleWidth(Math.max(Math.min(parentWidth, 800), 300));
jssor_slider2.$ScaleWidth(Math.max(Math.min(parentWidth, 800), 300));
}
The answer I found was to repeat this code for the amount of sliders you will be using:
function ScaleSlider() {
var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider1.$ScaleWidth(Math.max(Math.min(parentWidth, 800), 300));
else
window.setTimeout(ScaleSlider, 30);
var parentWidth = jssor_slider2.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider2.$ScaleWidth(Math.max(Math.min(parentWidth, 800), 300));
jssor is very nice slider! It is working well for a dynamically generated images. Thank you for the great tool. There is only one problem that remains.
The width of the slider container is 640px and I wanted the container to resize when the external container div becomes small. I does it well to diminish the image as desired. However,
1. when I resize the browser again and make a new image search. The slider occupy the entire external div width. So it only appear filling the entire area more than 640px width.
2. The responsiveness doesn't work on mobile devices. I tested in chrome and android browser both in android devices.
The codes I was using
Code 1:
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
function ScaleSlider() {
var parentWidth = $("#slider1_container").parent().width();
if (parentWidth) {
jssor_slider1.$ScaleWidth(parentWidth);
}
}
ScaleSlider();
//Scale slider while window load/resize/orientationchange.
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
Code 2:
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
if ( $(window).width() > 900 ) {
function ScaleSlider() {
var parentWidth = $("#slider1_container").parent().width();
if (parentWidth) {
jssor_slider1.$ScaleWidth(parentWidth);
}
}
}
//Scale slider after document ready
ScaleSlider();
if (!navigator.userAgent.match(/(iPhone|iPod|iPad|BlackBerry|IEMobile)/)) {
//Capture window resize event
$(window).bind("resize", ScaleSlider);
}
Please scale the slider no more than 640 in width.
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
function ScaleSlider() {
var parentWidth = $("#slider1_container").parent().width();
if (parentWidth) {
jssor_slider1.$ScaleWidth(Math.min(parentWidth, 640));
}
}
ScaleSlider();
//Scale slider while window load/resize/orientationchange.
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
I'm working in appcelerator and I have a tab which is the profile. On the top half there is the profile picture, the name, and other misc items, then on the bottom half is a twitter timeline. When i started putting on the twitter timeline code, it takes up the whole screen. Is there a way to reduce the timeline to only take up a portion of the screen to be able to see the other items?
This is my twitter timeline code:
var twitterUserName = "foundationsix";
var httpClient = Ti.Network.createHTTPClient();
httpClient.timeout = 10000;
httpClient.open("GET","http://api.twitter.com/1/statuses/" +
"user_timeline.json?count=10&screen_name=" + twitterUserName);
var twitterData = [];
httpClient.onload = function() {
try {
var tweets = JSON.parse(this.responseText);
for (var i=0; i < tweets.length; i++) {
var tweetText = tweets[i].text;
var user = tweets[i].user.screen_name;
var avatar = tweets[i].user.profile_image_url;
var created_at = tweets[i].created_at;
var row = Ti.UI.createTableViewRow({hasChild:true,
height:'auto'});
var postView = Ti.UI.createView({
height:'55',
top:5,
bottom:5,
left:5,
right:5,
});
var avatarImageView = Ti.UI.createImageView({
image:avatar,
left:0,
top:0,
height:48,
width:48
});
postView.add(avatarImageView);
var userLabel = Ti.UI.createLabel({
text:user,
left:54,
width:120,
top:-48,
bottom:2,
height:16,
textAlign:'left',
color:'#444444',
font:{fontFamily:'Trebuchet MS',fontSize:14,
fontWeight:'bold'}
});
postView.add(userLabel);
var dateLabel = Ti.UI.createLabel({
text:created_at,
right:0,
top:-18,
bottom:2,
height:14,
textAlign:'right',
width:110,
color:'#444444',
font:{fontFamily:'Trebuchet MS',fontSize:12}
});
postView.add(dateLabel);
var tweetTextLabel = Ti.UI.createLabel({
text:tweetText,
left:54,
top:0,
bottom:2,
height:'auto',
width:236,
textAlign:'left',
font:{fontSize:14}
});
postView.add(tweetTextLabel);
row.add(postView);
twitterData[i] = row;
}
var tableview = Titanium.UI.createTableView({data:twitterData,
minRowHeight:58});
win1.add(tableview);
}
catch(E) {
alert(E);
}
};
httpClient.send();
Please keep in mind .. We need to use either top and left or bottom and right.. dont mix up top and bottom in same element....
coming to solution to yours .. give top to table so that it goes down .......
i have created top view where you can specify username and etc
below you can post timeline
var win1=Ti.UI.createWindow()
///// this is top portion
var topView=Ti.UI.createView({
top:0,
left:0,
height:100,
background:"#2d2d2d"
})
var username=Ti.UI.createLabel({
text:"foundationsix",
color:"#fff"
})
topView.add(username)
win1.add(topView)
var twitterUserName = "foundationsix";
var httpClient = Ti.Network.createHTTPClient();
httpClient.timeout = 10000;
httpClient.open("GET","http://api.twitter.com/1/statuses/" + "user_timeline.json?count=10&screen_name=" + twitterUserName);
var twitterData = [];
httpClient.onload = function() {
try {
var tweets = JSON.parse(this.responseText);
for (var i=0; i < tweets.length; i++) {
var tweetText = tweets[i].text;
var user = tweets[i].user.screen_name;
var avatar = tweets[i].user.profile_image_url;
var created_at = tweets[i].created_at;
var row = Ti.UI.createTableViewRow({hasChild:true,
height:'auto'});
var postView = Ti.UI.createView({height:55});
var avatarImageView = Ti.UI.createImageView({
image:avatar,
left:0,
top:0,
height:48,
width:48
});
postView.add(avatarImageView);
var userLabel = Ti.UI.createLabel({
text:user,
left:54,
width:120,
top:-48,
bottom:2,
height:16,
textAlign:'left',
color:'#444444',
font:{fontFamily:'Trebuchet MS',fontSize:14,
fontWeight:'bold'}
});
postView.add(userLabel);
var dateLabel = Ti.UI.createLabel({
text:created_at,
right:0,
top:-18,
bottom:2,
height:14,
textAlign:'right',
width:110,
color:'#444444',
font:{fontFamily:'Trebuchet MS',fontSize:12}
});
postView.add(dateLabel);
var tweetTextLabel = Ti.UI.createLabel({
text:tweetText,
left:54,
top:0,
bottom:2,
height:'auto',
width:236,
textAlign:'left',
font:{fontSize:14}
});
postView.add(tweetTextLabel);
row.add(postView);
twitterData[i] = row;
}
var tableview = Titanium.UI.createTableView({
data:twitterData,
minRowHeight:58,
top:100
});
win1.add(tableview);
}
catch(E) {
alert(E);
}
};
httpClient.send();
win1.open()
var button = Ti.UI.createButton({
left: 180,
top: 180,
width: 100,
hight: 30,
title: 'Go'
});
self.add(button);
button.addEventListener('click', function() {
var xhr = Ti.Network.createHTTPClient();
var authstr = 'Basic ' +Titanium.Utils.base64encode('S0009231839'+':'+ 'm8390967743!');
xhr.open("GET","http://erp.esworkplace.sap.com/sap/bc/srt/wsdl/bndg_DF52FF9E9AF025F18F0400145E5ADE89/wsdl11/allinone/ws_policy/document?sap-client=800");
xhr.setRequestHeader('Authorization', authstr);
xhr.setRequestHeader('Content-Type','text/xml');
xhr.setRequestHeader('Accept-Language','en');
alert('show');
xhr.onload = function(e)
{ try
{
//get the xml data and let it roll!
var doc = this.responseXML.documentElement;
// var items = doc.getElementsByTagName("atom:entry");
var items = doc.getElementsByTagName("wsdl:portType");
for(var c=0; c<items.length;c++){
var item = items.item(c);
alert(items.length);
var attributeEmployeeLeave = items.item(c).attributes.getNamedItem("name").nodeValue;
Ti.API.info(items.item(c).attributes.getNamedItem("name").nodeValue);
}
}
catch(E)
{
alert('error on xhr');
}
The response for the button addEventListener is not working
I dont know why!
Any one can advice me!
Simple Button Example
var button = Titanium.UI.createButton({ title: 'Hello' });
button.addEventListener('click',function(e) {
Titanium.API.info("You clicked the button"); });
Please change your button.addEventListener('click', function() { to button.addEventListener('click', function(e) {.