Quantcast
Channel: Recent posts across whole site
Viewing all articles
Browse latest Browse all 49199

Help with map displaying Drupal JSON service

$
0
0

UPDATED

I'm working on adding points to a map from a drupal json service. I have it pulling the data in but its only placing one location and not all of them. Each location should get placed but it isn't. I'm not sure what I am doing wrong. Can anyone help? Below is the code.

Thanks

var lat = '';
var lon = '';

var url = 'http://localhost:8888/testsite/services/json';

var data = [];

var view = new Object;
view.method = 'views.get';
//view.hash = hash;
//view.domain_name = domain;
//view.domain_time_stamp = timestamp;
//view.nonce = nonce;
view.view_name = 'yardsales';

var xhr = Titanium.Network.createHTTPClient();
xhr.open("POST",url);

xhr.send({data: JSON.stringify(view)});

xhr.onload = function() {

Ti.API.info(this.responseText);

var data = JSON.parse(this.responseText);

Ti.API.info(data);

for (var c=0;c<data.length;c++)
{

data = Titanium.Map.createAnnotation({
    latitude:data[c]['locations'][0]['latitude'],
    longitude:data[c]['locations'][0]['longitude'],
    title:data[c]['locations'][0]['street'],
    subtitle:data[c]['field_date'][0]['value']+': Starting at '+data[c]['field_stime'][0]['value'],
    pincolor:Titanium.Map.ANNOTATION_RED,
    animate:true,
    rightButton: Titanium.UI.iPhone.SystemButton.DISCLOSURE,
    myid:(c+1)
});

Titanium.Geolocation.getCurrentPosition(function(e) {
    lat = e.coords.latitude;
    lon = e.coords.longitude;

var mapview = Titanium.Map.createView({
    mapType: Titanium.Map.STANDARD_TYPE,
    region: {latitude:lat, longitude:lon, latitudeDelta:0.01, longitudeDelta:0.01},
    animate:true,
    regionFit:true,
    userLocation:true,
    annotations:[data]
});

Titanium.UI.currentWindow.add(mapview);

});

}

};


Viewing all articles
Browse latest Browse all 49199

Trending Articles