Copy link to clipboard
Copied
I'm having an issue in building a yardsale map using jquery google map,while also providing some weather via a Json call to yahoo weather.
I'm placing map markers via a Json call of adresses. Placing the marker (if the adress is found) it builds the infowindow with info I provide (from the yardsale Json call). That works. I'm trying to add some weather data in each info window. I can get the data I need, and Assign it to a varaible, but when I try to bring it into the piece that places the info in the window, It comes as undefined.
I've tried placing the varible as a global variable outside the function (under the doc ready call)?
Can any body show/tell me how to get the vaiable to work (and why so I don't make the same mistake)
here is the code below:
$(document).ready(function() {
var val
var address="Boston, Mass"
var currdate
//weatherwidget (address)
$('#map_canvas').gmap('search', { 'address': 'Boston, Mass' }, function(results,isFound) {
if (isFound)
{
$('#map_canvas').gmap('get','map').panTo(results[0].geometry.location);
$('#map_canvas').gmap('option', 'zoom', 10);
}
});
$.getJSON('Yardsaleagate.json', function(yard_data)
{
$.each(yard_data.yardsales, function{
var val = this.address
var key = this.stuff
setTimeout(function(){
$('#map_canvas').gmap('search', { 'address': val }, function(results,isFound) {
if (isFound)
{
$.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%2...'+address+'%22%0A)%20limit%201&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?',function(data)
{
var currdate = (data.query.results.channel.item.forecast[0].date)
console.log(currdate)
})
$('#map_canvas').gmap('addMarker', { 'position': results[0].geometry.location, 'description': key, icon: "map-icons/pins/32/pin_ys.png",'animation': google.maps.Animation.DROP, 'info': val}).mouseover(function(){ weatherlocation(val)}).click(function() {
var infocontent = "<div class='info'>"+ currdate +"<div class='header'><h3>"+ val+" </h3></div> <p>"+this.description+"</><div>"
$('#map_canvas').gmap('openInfoWindow', { 'content': infocontent, 'maxWidth': 300 }, this);
});
}
})
}, i*700);
});
});
});
Figured it out (or a solution that works) move the infowindow build into the weather call infowindow will stll build
Copy link to clipboard
Copied
Moved thread from Dreamweaver CC to Developing Server-Side Applications in Dreamweaver for better responses.
Copy link to clipboard
Copied
Figured it out (or a solution that works) move the infowindow build into the weather call infowindow will stll build
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more