I’m trying to get the latitude and longitude from variable but I’m keep getting Unexpected token ,. I have tried to use var coordinates = 59.328615,13.485699 and var coordinates = '59.328615,13.485699' but I only got the same error. Now I’m out of ideas. What’s wrong?!
var coordinate_latitude = 59.328615;
var coordinate_longitude = 13.485699;
var marker;
var gm_map;
function initialize() {
var latlong = new google.maps.LatLng(coordinate_latitude, coordinate_longitude);
var googlemaps_options = {
zoom: 18,
minZoom: 4,
maxZoom: 18,
center: latlong,
mapTypeId: google.maps.MapTypeId.SATELLITE,
streetViewControl: false
}
gm_map = new google.maps.Map(document.getElementById('google-maps'), googlemaps_options);
marker = new google.maps.Marker({
position: latlong,
draggable: true,
map: gm_map
});
}
$(document).ready(function() {
// INITIERA GOOGLE MAPS
initialize();
});
Thanks in advance.
Thanks to Dr.Molle I got it working. geocodezip had also the correct answer but I’ll use Dr.Molles solution (
initialize();in$(document(ready(function() { ...). Here is the working code.