Здравствуйте, я пытаюсь определить местоположение пользователя с помощью API геолокации HTML5, а затем передать широту и долготу API AerisWeather
<div id="wxblox" class="aeris-wrapper"></div>
<script>
function cordinates() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
return position.coords.latitude + ',' + position.coords.longitude
}
);
}
else {
alert("Sorry, your browser does not support HTML5 geolocation.");
}
}
Aeris.wxblox.setAccess('secret', 'secret');
var view = new Aeris.wxblox.layouts.local.Main('#wxblox', {
obs: {
advisories: {
enabled: true
},
threats: {
enabled: true
}
},
nearby: {
request: {
limit: 4
}
},
shortterm: {
request: {
limit: 3
}
},
forecast: {
type: "detailed"
},
maps: {
animation: {
enabled: true,
autoplay: false,
alwaysShowPast: false,
alwaysShowFuture: false,
from: -2,
to: 0,
duration: 2,
endDelay: 1,
intervals: 10
},
controls: {
layers: [
{
code: "radar",
title: "Radar"
}, {
code: "satellite",
title: "Satellite"
}, {
code: "alerts",
title: "Advisories"
}, {
code: "temperatures,clip-us-flat",
title: "Temps"
}
],
regions: [
{
zoom: 7,
title: "Local"
}, {
zoom: 5,
title: "Regional"
}
]
}
}
});
cords = cordinates();
view.load({
p: cords
});
</script>
Можете ли вы сказать мне, где я не прав?API необходимо передать широту и долготу в этом формате - широта, долгота, например, - 42.000, 27.000. Например, этот жестко закодированный код работает:
<div id="wxblox" class="aeris-wrapper"></div>
<script>
Aeris.wxblox.setAccess('secret', 'secret');
var view = new Aeris.wxblox.layouts.local.Main('#wxblox', {
obs: {
advisories: {
enabled: true
},
threats: {
enabled: true
}
},
nearby: {
request: {
limit: 4
}
},
shortterm: {
request: {
limit: 3
}
},
forecast: {
type: "detailed"
},
maps: {
animation: {
enabled: true,
autoplay: false,
alwaysShowPast: false,
alwaysShowFuture: false,
from: -2,
to: 0,
duration: 2,
endDelay: 1,
intervals: 10
},
controls: {
layers: [
{
code: "radar",
title: "Radar"
}, {
code: "satellite",
title: "Satellite"
}, {
code: "alerts",
title: "Advisories"
}, {
code: "temperatures,clip-us-flat",
title: "Temps"
}
],
regions: [
{
zoom: 7,
title: "Local"
}, {
zoom: 5,
title: "Regional"
}
]
}
}
});
view.load({
p: "42.000, 27.000"
});
</script>