1

I am using services module to post nodes using rest/json. The nodes also contain images and location. So far I can upload the image and save the node, but the location is not saved. I receive no errors in logs.

Any ideas? Is there something I have to add,maybe permissions, in order to be saved?

This is the json that creates the article but doens not save the location.

{
    "title": "some title",
    "type": "article",
    "language": "el",
    "body" : {
          "und": [
              {
                  "value": "some text"
              } ]
    },
    "field_tags": { "und": "9" },
    "field_image": {
        "und": 
          [{
            "fid": "1364"
          }]

    },
    "locations":{
        "und":[
                {
                  "country":"gr",
                  "latitude":"55.7046601",
                  "longitude":"13.191007300000024",
                  "name":"TEST LOCATION",
                }
            ]
    }

}
0

How are you storing the location? Node location? Location CCK field?
take a look at:

https://www.drupal.org/node/906968

If you are using a CCK location field you should disable node location module.

  • Or if you aren't you could switch to a location field.

As a last option you could put latitude and longitude in their own text fields (like field_latitude and field_longitude) since gmaps module can take lat and lng from text fields.

you can use CCK location which allows you a geolocation field, it comes with location module:

https://www.drupal.org/project/location

|improve this answer|||||
  • I use drupal 7 and when I enabled the location/gmap module I see a default 'locations' field in the node. I also tried to create a new 'field_location' but no luck so far. The links that you sent is about drupal 6. – isin Apr 27 '16 at 9:30
  • Yep, but I found myself with the same problem in D7. If you want so use gmap and need a location field you can try: Location CCK which allows you to use a geolocation field and select this field as a coordinates source when you create a gmap view. – Miquel Correa Casablanca Apr 27 '16 at 9:38
  • There was some progress. I disabled 'node locations' and I posted to the new field_location the longtitude and latitude. But in table 'location' i see that source is 0 and the longtitude and latitude are both 0.000000. – isin Apr 27 '16 at 12:56
  • Make sure you pass the values in the right format with decimals after a dot – Miquel Correa Casablanca Apr 27 '16 at 12:58
  • I sent the following but still i get 0.00000... "field_location":{ "und":[ { "country":"gr", "latitude":"55.7046601", "longitude":"13.7046601", "name":"TEST LOCATION", "city":"Tripoli" } ] } – isin Apr 27 '16 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.