Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:18:46+00:00 2026-06-15T12:18:46+00:00

I don’t know how to search for this in SO, so I’m asking a

  • 0

I don’t know how to search for this in SO, so I’m asking a new question. What could cause or what is the concrete problem of my code: HTML generated by Javascript (createElement() and appendChild) is not being shown in Opera and Firefox, but it works in Chromium.

The HTML generating code:

function typesOfPlaces(map, bounds) {
  var allowedTypes = [
    "amusement_park",
    "aquarium",
    "art_gallery",
    "cemetery",
    "church",
    "city_hall",
    "hindu_temple",
    "mosque",
    "museum",
    "night_club",
    "park",
    "place_of_worship",
    "rv_park",
    "spa",
    "synagogue",
    "travel_agency",
    "zoo"
  ];
  var typesToDisplay = new Array();
  var request =  {
    bounds: bounds,
    types: allowedTypes
  };
  var service = new google.maps.places.PlacesService(map);
  service.nearbySearch(request, function(results, status) {
    if(status == google.maps.places.PlacesServiceStatus.OK) {
      for(var i = 0; i < results.length; i++) {
        for(var j = 0; j < results[i].types.length; j++) {
          for(var k = 0; k < allowedTypes.length; k++) {
            if(results[i].types[j] == allowedTypes[k]) {
              var allowed = true;
              for(var x = 0; x < typesToDisplay.length; x++) {
                if(allowedTypes[k]==typesToDisplay[x]) {
                  allowed = false;
                }
              }
              if(allowed) {
                typesToDisplay.push(allowedTypes[k]);
              }
            }
          }
        }
      }
      var parent = document.getElementById("types");
      for(var i = 0; i < typesToDisplay.length; i++) {
        var typeBox = document.createElement("div");
        var checkBox = document.createElement("input");
        var checkID = randomString(10);
        var label = document.createElement("label");
        checkBox.setAttribute("type", "checkbox");
        checkBox.setAttribute("id", checkID);
        label.setAttribute("for", checkID);
        label.innerHTML = typesToDisplay[i];
        typeBox.appendChild(checkBox);
        typeBox.appendChild(label);
        parent.appendChild(typeBox);
      }
    }
  });
}//END OF Function

UPDATE TO COMMENTS

The randomString is just SO’ed code for generating random string:

function randomString(L) {
  var s= '';
  var randomchar=function() {
    var n= Math.floor(Math.random()*62);
    if(n<10) return n; //1-10
    if(n<36) return String.fromCharCode(n+55); //A-Z
    return String.fromCharCode(n+61); //a-z
  }
  while(s.length< L) s+= randomchar();
  return s;
}

div #types really exists, it look like this:

<html>
  <head>
    ...
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=MyKey&sensor=false&libraries=places&language=lt"></script>
  </head>
  <body>
    <div>
      <div>
        <div id="types"></div>
      </div>
    </div>
  </body>
</html>

You can see the import of google.maps.places.PlacesService by looking at the <head> section of the <script> tag, where you can see “&libraries=places”.

SECOND UPDATE AFTER SOME TESTING

ok. I’ve figured out that if I deny location sharing in opera it works (it works in chromium because by default it does not even ask user if he is kind to share his geolocation with website)

The code for geolocation:

function initGeo()
{
    if (navigator.geolocation)
    {
        navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
    }
    else
    {
        errorFunction();
    }
}

so, the function that does not work is successFunction (which is being launched if user kindly shares his geolocation)

function successFunction(position)
{
    var geocoder = new google.maps.Geocoder();
    var abstract_location;
    var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
    geocoder.geocode({'latLng': latlng}, function(results, status) 
    {
        if (status == google.maps.GeocoderStatus.OK) 
        {
            abstract_location = new google.maps.LatLngBounds(
                results[0].geometry.viewport.getSouthWest(), 
                results[0].geometry.viewport.getNorthEast());
        }
        else
        {
            alert("NOT SUCCESS 1");
        }
        showGMap(latlng, abstract_location);
    });
}

And the errorFunction, which successfully works on chromium by default and on Opera if you deny access to your geolocation:

function errorFunction(error)
{
    var geocoder = new google.maps.Geocoder();
    if(google.loader.ClientLocation)
    {
        var latlng = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
        geocoder.geocode({'latLng': latlng}, function(results, status) 
        {
            if (status == google.maps.GeocoderStatus.OK) 
            {
                var abstract_location = new google.maps.LatLngBounds(
                    results[0].geometry.viewport.getSouthWest(), 
                    results[0].geometry.viewport.getNorthEast());
            }
            else
            {
                alert("NOT SUCCESS 2");
            }
            showGMap(latlng, abstract_location);
        });
    }
    else
    {
        geocoder.geocode( {'address': 'Vilnius Region, Lithuania'}, function(results, status) 
        {
            if (status == google.maps.GeocoderStatus.OK) 
            {
                var latlng = results[0].geometry.location;
                var abstract_location = new google.maps.LatLngBounds(
                    results[0].geometry.viewport.getSouthWest(), 
                    results[0].geometry.viewport.getNorthEast());
                showGMap(latlng, abstract_location);
            }
            else
            {
                alert("NOT SUCCESS 3");
            }
        });
    }
}

Nor Chromium nor Opera does not give me ANY errors, nor javascript exceptionaly, nor in general.

So the problem is in success function. Because it even does not give me alert(typesToDisplay.length) [as suggested by Stuart in the comments] – it means that there is no alert at all – in case of error function I get the aswer 4 and thus i can see my generated HTML.

In case of success function there is just empty (without any appended childs) #types .

I do not see what could be causing success function to be NOTSUCCESS (:))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:18:47+00:00Added an answer on June 15, 2026 at 12:18 pm

    Ok, so i have figured it out – it was pretty simple though…

    The Geolocation data which you get is an address, so bounds are very small, you have to extract city with reverse geocoding (results[6].formatted_address) and then you geocode that reverse geocode (so confused though Geocoding -> reverse -> again geocode) and then it works!

    So the problem was at geocoding (haven’t thought that bounds of address is not the whole city (that should have been obvious in the first place, but was not).

    HTML5 geocoding could have the info about the city (not only lan and lng, firefox has something, but that’s only firefox, not the whole HTML5), but i do not know if it would be good or not (lack of my personal knowlede at the moment in this specific field)

    So if anyone does get to something similar -> check the bounds 😉

    Thank you for your comments and for your view’s.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know why, but this code worked for me a month ago... maybe
This could be a duplicate question, but I have no idea what search terms
Don't know if this has been asked before, so point me to another question
Don't know if this is an eclipse specific problem but whenever I declare a
Don't know why it's not working, i think the code is fine - could
don't know better title for this, but here's my code. I have class user
Don't know how to frase this but I found this code wich works as
Don't be scared of the extensive code. The problem is general. I just provided
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
Don't know if anyone can help me with this or if it's even possible.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.