Google Maps API Geocode gives "Invalid Label" error in Firefox

Today I struggled with the following:

$.ajax({url:'http://maps.google.com/maps/api/geocode/jsonaddress=Karachi&sensor=false&output=json&callback=?',
        dataType: 'json',
        success: function(data){
         //eval("("+data+")");
         alert(data);
        }
});

Firefox gives the error message "Invalid label" and "SyntaxError malfunction: Unexpected token": "I found a lot of messages about this, and I tried all kinds of things like eval (), but also:

$.getJSON('http://maps.google.com/maps/api/geocode/jsonaddress=Karachi&sensor=false&output=json&callback=?',
 function(data){
  //eval("("+data+")");
  alert(data);
 }
);

The same result. In addition, other json data works fine, for example flickr (" http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback= ?). So it’s somehow connected with google maps api output i think ..

Thanks in advance.

+3
source share
2

; AFAIK Geocoder V3 callback=?.
.

0

V3, $.getJSON , api , , .

var  geocoder = new google.maps.Geocoder();
 geocoder.geocode( { 'address': '10 downing street, London, UK'}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        console.log(results);
        alert(results[0].geometry.location);

      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });

.... https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingRequests

https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-simple

+2

Source: https://habr.com/ru/post/1742139/


All Articles