[Users] gx_geocodercombo with Google Geocoder

"Christian Röttger" cromail at gmx.de
Mon Sep 9 17:46:50 CEST 2013


Hello everybody,

i'm trying to use a geocodercombobox with the Google Geocoder Service. But in Chrome i get the following error in the console when i enter a address:
Uncaught SyntaxError: Unexpected token :
and in firefox: 
SyntaxError: invalid label "results" : [

I don't understand the problem, because the json i'm getting back seems to be ok and returns values and status ok. Maybe anyone can see my mistake or give me a hint or link to an working example.

Thanks Christian

This is my code block:
{
	xtype: 'gx_geocodercombo',
	itemId: 'startGeocombobox',
	margin: '3 0 0 10',
	emptyText: "Google Adresse suchen ...",
	queryParam: 'address',
	locationField: 'latLng',
	queryDelay: 300,
	zoom: 13,
	url: 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&language=de',
	width: 260,
},

This is the json response i get for Münster: 
{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Nordrhein-Westfalen",
               "short_name" : "NRW",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Deutschland",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Münster, Deutschland",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 52.0600197,
                  "lng" : 7.774361699999999
               },
               "southwest" : {
                  "lat" : 51.84015110000001,
                  "lng" : 7.473832599999999
               }
            },
            "location" : {
               "lat" : 51.9606649,
               "lng" : 7.6261347
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 52.0600197,
                  "lng" : 7.774361699999999
               },
               "southwest" : {
                  "lat" : 51.84015110000001,
                  "lng" : 7.473832599999999
               }
            }
         },
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "North",
               "short_name" : "North",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Lake County",
               "short_name" : "Lake County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Indiana",
               "short_name" : "IN",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "USA",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Münster, Indiana, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 41.581235,
                  "lng" : -87.48013999999999
               },
               "southwest" : {
                  "lat" : 41.5227349,
                  "lng" : -87.5250411
               }
            },
            "location" : {
               "lat" : 41.5644798,
               "lng" : -87.5125412
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 41.581235,
                  "lng" : -87.48013999999999
               },
               "southwest" : {
                  "lat" : 41.5227349,
                  "lng" : -87.5250411
               }
            }
         },
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}


More information about the Users mailing list