No se muestra el mapa de Google Maps pero sí los controles

I'm fetching the coordinates from the URL that looks like this (part of it of course): weather/59.328676,13.485656. Now, I have extract these coordinates using a function. When I am trying to load Google Maps, the controls shows but not the actual map. You can see what I mean by clicking on this link: http://server-1.myftp.org/vadret-just.nu/weather/59.328676,13.485656. The code I'm using are this:

function url_endstring(url){
    return url.substr(url.lastIndexOf('/') + 1);
}


var coordinates = url_endstring(window.location.href);
var latlng = new google.maps.LatLng(coordinates);
var map_options;
var gm_map;
var marker;

function initialize() {
    latlng;
    map_options = {
        center: latlng,
        zoom: 12,
        mapTypeId: google.maps.MapTypeId.ROADMAP,

        streetViewControl: false,

        zoomControlOptions: {
            style: google.maps.ZoomControlStyle.SMALL
        }
    };

    gm_map = new google.maps.Map(document.getElementById('google-maps'), map_options);

    marker = new google.maps.Marker({
        position: latlng,
        map: gm_map
    });
}

Have I missed something? How can I make the Google Maps map visible?

preguntado el 10 de septiembre de 13 a las 01:09

Try moving your initialize function out of the window onload event. -

Your code works as is.The problem may be due to css styling. -

Thanks for your answers but none of them did help me :/ My initlialize function are outside of the window onload event as I can see it. If I remove background-image from #google-maps in my stylesheet, only the background image disappears and a greyish background appears instead of the actual map. -

Worth saying is that if I replace var latlng = new google.maps.LatLng(coordinates); con var latlng = new google.maps.LatLng(59.328676,13.485656); the map shows as it should -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.