lundi 13 septembre 2010

Make a LAYAR layer (the hard way)

First draft! (This is the hard way, for the soft way see the next post.)

In principle to get a layar you have to set up a database with the points of interest.Then put a php script on your server.Then make a layar on the developers site of layar.com and you can test it.

( you can find the layar tutorial at: http://layar.pbworks.com/First+Layar+Tutorial+-+Create+a+simple+layer but of course this leaves out the how to get your own server and ftp etc.)

  1. create a developpers account on http://publishing.layar.com/ this may take a day.
  2. when you are registered activate account etc.
  3. for your account you need a server, a free server can be obtained here: www.freebyte.com
  4. register an account here and activate.
  5. go to controlpanel and log in: http://panel.byethost.com
  6. go to databases and take the link MySQL databases

  7. make a database called LAYAR
  8. go admin (on this page too, to the right of the Backup button)
  9. go SQL you get a window to put in code
  10. insert a code to make a table:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

CREATE TABLE IF NOT EXISTS `POI_Table` (
`id` int(50) NOT NULL auto_increment,
`attribution` varchar(50) default NULL,
`title` varchar(50) default NULL,
`lat` decimal(20,10) default NULL,
`lon` decimal(20,10) default NULL,
`imageURL` varchar(255) default NULL,
`line4` varchar(50) default NULL,
`line3` varchar(50) default NULL,
`line2` varchar(50) default NULL,
`type` int(11) NOT NULL default '0',
`actions` varchar(50) default NULL,
`dimension` int(1) NOT NULL default '1',
`alt` int(10) default NULL,
`relativeAlt` int(10) default NULL,
`transform` int(10) default NULL,
`object` int(10) default NULL,
`distance` decimal(20,10) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
  1. click start and the tabel will be made.
  2. now we add some data:
  3. go SQL again and to get a few entries fast insert (and press the start button):
INSERT INTO `POI_Table` (`id`, `attribution`, `title`, `lat`, `lon`, `imageURL`, `line4`, `line3`, `line2`, `type`, `actions`, `dimension`, `alt`, `relativeAlt`, `transform`, `object`, `distance`) VALUES
(2, 'acadmie richting 2', 'acadmie richting 2', '51.9180000000', '4.4900000000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance%', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.0000000000'),
(3, 'acadmie richting 3', 'acadmie richting 3', '51.9170780000', '4.4890170000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance%', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.0000000000'),
(4, 'acadmie richting 3', 'acadmie richting 3', '51.9181360000', '4.4852400000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance%', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.0000000000'),
(5, 'acadmie richting 4', 'acadmie richting 4', '51.9204130000', '4.4860980000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance%', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5.0000000000'),
(18, 'street', 'blaak', '51.9170000000', '4.4955000000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance% ', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.0000000000'),
(20, 'boulevard', 'weena', '51.9175000000', '4.4954000000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance% ', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.5000000000'),
(17, 'marker', 'hello rotterdam', '51.9171800000', '4.4953000000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance% ', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.0000000000'),
(19, 'street', 'coolsingel', '51.9176000000', '4.4952000000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance% ', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.0000000000'),
(16, 'architecture', 'where do you want to be', '51.9169000000', '4.4951000000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance% ', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.0000000000'),
(15, 'architecture', 'where do you want to be', '51.9800000000', '4.6000000000', 'http://custom.layar.nl/layarimage.jpg', NULL, 'distance:%distance% ', NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.0000000000'),
(21, 'house', 'my home', '51.9140000000', '4.4280000000', 'http://custom.layar.nl/layarimage.jpg', NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, '5000.5000000000');

  1. now first we need to put a script on the server you have created to find the POI's in the table you just made: go to your FTP program, I use firefox with FireFTP.
  2. make an account in your FTP program and log in, you find the login name and password in your bytehost documentation
  3. make folder called "layar"
  4. now copy the file called "FirstTutorial_POI.php" from the download you find on this pae: http://layar.pbworks.com/First+Layar+Tutorial+-+Create+a+simple+layer just above number 6 testing the layar
  5. rename this file: so FirstTutorial_POI.php becomes "layar_POI.php"
  6. open this file in textEdit (or alike)
  7. now you have to change the login and passwords in the file to the ones you got from bytehost:

$dbhost = "localhost";// local host must become "sqlxxx.byethostxx.com", where xx are your numbers
$dbdata = "database_name";//"bxx_xxxxxxx_LAYAR", where xx are your numbers
$dbuser = "database_username";//"bxx_xxxxxxx"
$dbpass = "database_password";// your password

save the file and upload in the "layar" folder.
  1. go to the developers site of layar: http://publishing.layar.com/publishing/layers/
  2. login etc
  3. create layar
  4. now you get the first screen with properties of the layar,
  5. give your layar a title
  6. now fill in the link to the file on your database: http://YOURNAME.byethost31.com/layar/layar_POI.php, where YOURNAME is the name of your bytehost account
  7. do a SAVE
  8. file in the tabs LISTING and DETAILS, indicated in red
  9. The last tab FILTERS, i use to set the range slider to 50000 (meters) which is easy for testing
  10. in principle this should work, that is you can test the page on the API Test Page of layar
  11. later on you can test on your cell phone



Aucun commentaire:

Enregistrer un commentaire