Getting Started

12 views
Skip to first unread message

aaron

unread,
Feb 18, 2011, 4:33:36 PM2/18/11
to GeoIQ Developer
Trying to use REST API to create a map.

I am following the basic instructions I have found here

http://geocommons.com/help/Visualization_API , specifically create a
map.

I am doing a post
I am passing in my credentials
I am getting a {"error": "invalid request"}

I have cut and pasted the code directly... I am stumped

Kate Chapman

unread,
Feb 18, 2011, 4:41:06 PM2/18/11
to geoiq-d...@googlegroups.com, aaron
Hi Aaron,

I just did the following combination:

cat map.json | curl -i -u "username:password" -d @- -X POST
http://geocommons.com/maps.json -H "Content-Type:application/json"

With the following json:

{
title: "Map Title",
description: "A description",
tags: "example,tags,more",
extent: [-180,-90,180,90], // [west,south,east,north] -
longitude, latitude decimal degrees - WGS84
basemap: "Google Terrain", // deprecated - will soon be using
Finder raster layers
projection: "EPSG:3785", // not supported yet (default EPSG:3785
- Web Spherical Mercator, aka 'Google Tiles')
}

Were you using a different example that did not work? Could you paste
it into your message?

Thanks,

Kate

aaron

unread,
Feb 18, 2011, 5:36:31 PM2/18/11
to GeoIQ Developer
I am trying to do this with appcelerator, not CURL

was wondering where I can find documentation on the parameters passed
in the JSON string?

On Feb 18, 4:41 pm, Kate Chapman <k8chap...@gmail.com> wrote:
> Hi Aaron,
>
> I just did the following combination:
>
> cat map.json | curl -i -u "username:password" -d @- -X POSThttp://geocommons.com/maps.json-H "Content-Type:application/json"
>
> With the following json:
>
>  {
>      title: "Map Title",
>      description: "A description",
>      tags: "example,tags,more",
>      extent: [-180,-90,180,90],    // [west,south,east,north] -
> longitude, latitude decimal degrees - WGS84
>      basemap: "Google Terrain", // deprecated - will soon be using
> Finder raster layers
>      projection: "EPSG:3785", // not supported yet (default EPSG:3785
> - Web Spherical Mercator, aka 'Google Tiles')
>  }
>
> Were you using a different example that did not work?  Could you paste
> it into your message?
>
> Thanks,
>
> Kate
>
>
>
>
>
>
>
> On Fri, Feb 18, 2011 at 1:33 PM, aaron <aaronksaund...@gmail.com> wrote:
> > Trying to use REST API to create a map.
>
> > I am following the basic instructions I have found here
>
> >http://geocommons.com/help/Visualization_API, specifically create a

Kate Chapman

unread,
Feb 18, 2011, 6:13:15 PM2/18/11
to geoiq-d...@googlegroups.com, aaron
Hi Aaron,

We did a little bit of work with GeoIQ and Appcelerator at a hack day.
Some of the API calls are here:
https://github.com/fortiusone/Flying-Pancakes/blob/master/Resources/geoiq.js

At the moment we are cleaning up our documentation. I'll see about
getting the map portion into better shape in the next day or two.

Thanks,

Kate

aaron

unread,
Feb 19, 2011, 10:42:00 AM2/19/11
to GeoIQ Developer
I took a look at that code and none of those examples create a map?

Looking forward to updated documentation

On Feb 18, 6:13 pm, Kate Chapman <k8chap...@gmail.com> wrote:
> Hi Aaron,
>
> We did a little bit of work with GeoIQ and Appcelerator at a hack day.
>  Some of the API calls are here:https://github.com/fortiusone/Flying-Pancakes/blob/master/Resources/g...

Kate Chapman

unread,
Feb 21, 2011, 9:13:02 PM2/21/11
to geoiq-d...@googlegroups.com, aaron
Hi Aaron,

I haven't gotten as far as I hoped with updating the documentation.
It is currently an ongoing work to make things more clear.

I have updated some things for creating a map here:
https://docs.google.com/document/d/14Zg514AMWpfpR6rLW93bCTSbXf58ywE3jnwZr1rOWQo/edit?hl=en&authkey=CJbi58QP

You definitely need the title and basemap parameters for creating a
map. Could you try it with just those and let me know what happens.
Also if you could share your code so far that would greatly help.

Thanks,

Kate

aaron

unread,
Feb 23, 2011, 10:24:40 PM2/23/11
to GeoIQ Developer
here is my code

// get the login information and let it roll!!
try {
var xhr = Titanium.Network.createHTTPClient();

xhr.open("POST","http://geocommons.com/maps.json");

// set credentials
var authstr = 'Basic '
+Titanium.Utils.base64encode("aaronksaunders:password");
xhr.setRequestHeader('Authorization', authstr );
xhr.setRequestHeader('content-Type', "application/json" );

xhr.onerror = function(e)
{
Ti.API.info("ERROR " + e.error);
};

xhr.onload = function() {
Titanium.API.log(xhr.responseText);
};

xhr.onreadystatechange = function (aEvt) {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
Titanium.API.log("status 200 ");
}
}
};
var param = JSON.stringify({
title: "Map Title",
description: "A description",
tags: "example,tags,more",
extent: [-180,-90,180,90],
basemap: "Google Terrain",
projection: "EPSG:3785"
});
Titanium.API.log(param);
xhr.send(param);
} catch(err) {
Titanium.UI.createAlertDialog({
title: "Error",
message: String(err),
buttonNames: ['OK']
}).show();
}

On Feb 21, 9:13 pm, Kate Chapman <k8chap...@gmail.com> wrote:
> Hi Aaron,
>
> I haven't gotten as far as I hoped with updating the documentation.
> It is currently an ongoing work to make things more clear.
>
> I have updated some things for creating a map here:https://docs.google.com/document/d/14Zg514AMWpfpR6rLW93bCTSbXf58ywE3j...
Reply all
Reply to author
Forward
0 new messages