I need to code for label on the map as product price in Titanium SDK.
Anybody have any idea how to achieve this ?
Waiting for your kind response.
What i get from your question is that when you click on a map marker ( product in your case ) , you what to show price of that item as an info window ( for that marker ).
If this is the case then set title of your annotation as the product price.
Something like ( example taken from titanium docs) :
var Map = require('ti.map'); //extend map global object
var win = Titanium.UI.createWindow();
var mountainView = Map.createAnnotation({
latitude:37.390749,
longitude:-122.081651,
title:"Appcelerator Headquarters", //<--------- YOUR PRODUCT PRICE HERE
subtitle:'Mountain View, CA',
pincolor:Map.ANNOTATION_RED,
myid:1 // Custom property to uniquely identify this annotation.
});
var mapview = Map.createView({
mapType: Map.NORMAL_TYPE,
region: {latitude:33.74511, longitude:-84.38993,
latitudeDelta:0.01, longitudeDelta:0.01},
animate:true,
regionFit:true,
userLocation:true,
annotations:[mountainView]
});
win.add(mapview);
// Handle click events on any annotations on this map.
mapview.addEventListener('click', function(evt) {
Ti.API.info("Annotation " + evt.title + " clicked, id: " + evt.annotation.myid);
});
win.open();
Related
Currently in ArcGIS Online if multiple items exist in a single point the template is shown like this
Will I be able to view the details with the number of elements as a part of the template like this
You can retrieve the number of selected features using Popup.featureCount.
The following CodePen uses this property to provide a dynamic PopupTemplate.title: https://codepen.io/arnofiva/pen/5b532f8577d097107cf8040da57e0b97
var template = layer.popupTemplate;
var defaultTitle = template.title;
// Compute popup title before it is shown
template.title = function() {
var total = view.popup.featureCount;
if (total > 1) {
return defaultTitle + " - Count: " + total + "";
} else {
return defaultTitle;
}
}
See the following ArcGIS API for JavaScript resources for more information on popups and widgets:
Popup Widget
PopupTemplate - use functions to set content
Popup with DOM node
Widget development - ViewModel pattern
I have a Google map driven by Advanced Custom Fields. I have created an iconType to dictate which icon is used as the marker depending on the custom field.
My marker images are 80px square but I want to force them to 40px square for retina reasons. I have tried lots of variations of code I've found via google etc but nothing works and the size gets ignored showing my markers at the larger 80px. My guess is because I have the 2 icons depending on iconType?
Can anyone help me force the size of these markers to 40px square please...
function add_marker( $marker, map ) {
// var
var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng'));
var iconType = $marker.attr('data-icon');
var iconBase = '<?php echo get_template_directory_uri(); ?>/assets/';
var size = new google.maps.Size(40, 40);
if (iconType === 'Costa') {
iconName = 'costa#2x.png';
} else {
iconName = 'starbucks#2x.png';
}
// create marker
var marker = new google.maps.Marker({
position : latlng,
map : map,
clickable: false,
animation: google.maps.Animation.DROP,
icon: iconBase + iconName,
});
// add to array
map.markers.push( marker );
// if marker contains HTML, add it to an infoWindow
if( $marker.html() )
{
// create info window
var infowindow = new google.maps.InfoWindow({
content : $marker.html()
});
}
}
I did something like this recently, and I believe you'll need to use the new Icon object to specify your custom Icon properties, and use the size and scaledSize properties. I fixed my issues following this guide:
How to add retina ready pin marker to your Google maps?
I have the following code that creates a new annotation on my .js:
//Create annotation
var new_annotation = Titanium.Map.createAnnotation({
latitude:10,
longitude:30,
title:"Title",
pincolor:Titanium.Map.ANNOTATION_RED,
customdata:"My custom data",
animate:true,
rightButton: Titanium.UI.iPhone.SystemButton.DISCLOSURE,
myid:1
});
$.mapview.addAnnotation(new_annotation);
All information like title, latitude and longitude is available on my click function:
function doClick(evt){
alert("title: " + evt.title);
alert("customdata: " + evt.customdata);
};
However customdata is "undefined".
How can save and retrieve data from a Titanium MapView Annotation? Why the data is "undefined"?
You are adding your customdata object to the annotation itself, the evt object that is passed into the click event listener is defined in the DOCS as passing the title of the annotation explicitly, so of course you can retrive it, but to get the customdata you have to do this:
function doClick(evt){
alert("title: " + evt.title);
// Get the annotation, then get the custom data attached to it
alert("customdata: " + evt.annotation.customdata);
};
i am new to titanium development.i am developing ToDo application using Titanium for learning purpose.i able to display the data from database and generate tableViewRow successfully but i am stuck in one phase that i unable to display button in each row.i did R&D for it but i cant get solution.here is my code for display buttons in each row of tableViewRow it display all records from database in each row but not buttons.it shows [object TableViewRow] in each row instead of button. so please help me to solve the issue
![Titanium.UI.setBackgroundColor('black');
var win = Titanium.UI.createWindow
({
title:'Tab 1',
backgroundColor:'#fff'
});
var db = Titanium.Database.install('/mydata/ToDoDB', 'ToDoDB');
var rows = db.execute('SELECT * FROM task');
var data1=[];
while(rows.isValidRow())
{
var rowview=Titanium.UI.createTableViewRow();
var btn=Titanium.UI.createButton
({
right:'20dp',
width:'60dp',
height:'40dp',
title:'Show'
});
rowview.add(btn);
var tt=rows.fieldByName('title');
var cc=rows.fieldByName('content');
//data1.push({title:rows.fieldByName('title')},{title:rows.fieldByName('content')},{title:rowview});
data1.push({title:tt+cc+rowview});
rows.next();
//rowview.add(btn);
};
rows.close();
var yourTable = Ti.UI.createTableView
({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
data: data1
});
db.close();
win.add(yourTable);
win.open();
Try the following
var rowview = Titanium.UI.createTableViewRow();
var tt=rows.fieldByName('title');
var cc=rows.fieldByName('content');
var btn=Titanium.UI.createButton({
right:'20dp',
width:'60dp',
height:'40dp',
title:'Show'
});
var labeltt=Titanium.UI.createLabel({
left:'20dp',
width:'60dp',
height:'40dp',
text:tt
});
var labelcc=Titanium.UI.createLabel({
left:'80dp',
width:'60dp',
height:'40dp',
text:cc
});
rowview.add(labeltt);
rowview.add(labelcc);
rowview.add(btn);
data1.push(rowview);
I didn't tried this code, so there should be some alignment issues. I hope this will help you
what you are looking for is a custom row once you start including buttons and such.
Here is a old but still informative example
http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/
Basic idea is that you create a view, place it in the row, and then add the additional row UI object into that view
i am trying to make the same app with the miamicode, i am at step 3
http://miamicoder.com/2012/how-to-create-a-sencha-touch-2-app-part-3/
i try to make the button that goes to new note (switch to a new screen and create a new note)
the code at the example is this:
onNewNoteCommand: function () {
console.log("onNewNoteCommand");
var now = new Date();
var noteId = (now.getTime()).toString() + (this.getRandomInt(0, 100)).toString();
var newNote = Ext.create("NotesApp.model.Note", {
id: noteId,
dateCreated: now,
title: "",
narrative: ""
});
this.activateNoteEditor(newNote);
}
the activateNotesList function is this :
activateNotesList: function () {
Ext.Viewport.animateActiveItem(this.getNotesListView(), this.slideRightTransition);
on my own example i try just to go the editview without passing data.
so i try this:
onNewNoteCommand:function()
{
var noteEditor = this.getNoteEditor();
// Ext.Viewport.add(noteEditor); also tried this.
Ext.Viewport.setActiveItem(noteEditor);
that code runs with no errors but the screen doesn't change.
any suggestion? whats the difference on add ?
how do i set the viewport (haven't created any custom viewport) to card? is this the problem that setactiveitem doesn't work? any other way to switch between views?
Are there some errors in google chrome browser's console? Ctrl+Shift+J to open.
Also you have to check if noteEditor equals Object or Number.
From sencha docs: setActiveItem( Object/Number activeItem )