The first day in my Nokia internship was also my first contact with Places API, and my task was to use
the first week to “get to know each other”, so that’s what I did. The best way
to achieve it is to read both, the getting
started guide and the developer’s guide,
this last one at least until the attributes section, the following parts you
can leave them for later, when you get more familiar with the API.
After a first glance in the documentation you can see that
there are two big parts in the Places API:
The first is called the “Headless API”some
functions to access the Nokia servers and make searches and queries and for the
raw information about places.
The second are the templates:
the cool stuff! With them you can put everything that the API has quick and
easily in your web page, and it will look really nice! Well, more or less quick
an easy, we’re not talking about drag and drop here. It’s more like copy-paste
the code, then do some small tweaking and “voilà”!
To do that, you don’t need much, in my first contact I had this in my pocket: a
basic level of html, a very basic level of css, and almost 0 level on
javascript. And I managed pretty much everything. Although I have to say, that
due to my lack of javascript when I wanted to do more complicated things than
the ones in the developer’s guide, I advanced very slowly.
So don’t be scared, you don’t need to learn a whole new programming language to
use the API, apart from the basic web knowledge (html+css+javascript), you just
need to get familiar with this thing called “templates” and its “attributes”
and you’re ready to go.
If you decide to start with Places API, my advice is that
when following the developer’s guide, you shouldn’t just read it, but also copy
the code examples in your own test webpage to see that is working. You don’t
need to download anything to use the API, just a web browser and internet
connection is enough.
Some examples will require you to make small changes in the
code to make them work. For example in the “A
custom template” section, to use the
custom template you will need this piece of code:
var place = new nokia.places.Place({ template: "myTemplate", targetNode: "renderMyTemplateHereId" });
place.setData (object);
<script id="myTemplate" type="text/template">
<div> <p fill="{name}"></p> <p fill="{fullAddress()}"></p>
<ul each="{media[supplier.name=='orange']}">
<li fill="{URL}"></li> </ul>
</div> </script>
But, for it to work you need to declare the object variable
used in place.setData (object).You
can just use the object defined at the beginning of the section, like this:
var object = { name: 'Le Marfil', contact: {
description: 'Home away from home' }, location: { address: { … };
Or you could also use some standard place object. To do that
change the
place.setData(object);
For the following line:
place.setPlaceId('250u09tv-fc09ac6bdbe340e9b5e2ad78efc814d0');
That will get an object with all the place information, you
can change the placeId with any other valid one of your liking (get them here).
As you see, it’s with small tweaking like that you and the
API will start to “get to knodw each other”
