Previously, we were able to generate this map with this marker, which has a popup window with a simple
string.
In this lecture, I'm going to show you how to show the weather forecast data instead of this string
in this popup window.
So let's do that.
This is the cool we have this for we believe that in the previous lecture video to show the weather
forecast for that particular point is simple, but it's a bit tricky.
So we have this latitude and longitude coordinates and we are producing the map, which is centered
in those latitude and longitude coordinates.
And then we create a dewpoint object which is plotted in the same coordinates.
So those two values and it happens to be in the center of the map.
But that's just a coincidence.
You can have the center coordinates different from the geo coordinates.
That would be fine, too.
Now, in the Geo Point class, we also have this gets weather method, which returns the weather forecasts.
So what we can do is instead of the simple string, we could do geo points that get weather.
So call the method of geo points.
And this will not work, but we can try.
So when you execute that, you get this error, it says that dewpoint is not defined in life.
So here, you know, if you have that argument in the same line and executes it again, it's the same
error.
So name error.
Your point is not the difference.
This time is in line 12.
So you get the same error no matter if you split the line or not.
This is basically for Python.
This is the same line.
So dewpoint is not defined well, but we are defining it here.
Yes, we are defining it.
But the way Python executes the code is it starts from the first line from left to right.
It executes that.
Then it goes here and here and here and here and then it goes here.
So it creates this identifier and then it tries to associate an object with that identifier.
The object is this one in here.
So Python tries to evaluate this expression here.
So dewpoint, latitude, latitude and longitude, longitude, the right popup equal to dewpoint that
gets whether.
But what is this dewpoint?
This object has not been created yet because we are trying to create it in this line.
But this line has not finished is its execution just yet.
So this is too early to access something from the geo points object.
One viewpoint has not been created yet and one solution you could have is to first create the dewpoint
object without the popup.
And then once you have that object, then you can again override that object.
But this time you add the dewpoint that gets you whether method to the argument of that object.
So we created the object here first using the same latitude and longitude, and then we start to create
another object.
And at this point, Python will access that dewpoint that was generated in there and will access as
the gateway other method from that dewpoint.
And then after this ends, these dewpoint overrides at that point.
But in addition, it also has this pop up arguments and you see that this time things will work fine.
So reload the map control or
click on the marker.
And these are the weather forecasts.
So it's a list of tuples.
The first tuple there was second and so on.
Things are working, however, it's not ideal to instantiate an object twice because it will make the
script slower and it will have an impact on the memory, even though this is just a small object.
But as a rule, you shouldn't do that.
So you should look out for better ways to do this.
And one way is to you know, if you look at the import volume and then see what you have available,
what objects you have available directly from volume, you see pop up.
So pop up is a type you see type of volume that pops up to see.
It's a type just like map is a type, pop up is also a type.
And if you look at the pop up, you'll see it has an add two methods, which includes the pop up to
a marker.
So what we can do is I'm going to delete that line and I'm going to import pop up.
And so then we create the dewpoint object and then we create a popup
object, which could get a string as input.
So for now, let me put again hi there.
Before putting directly the dewpoint that get to other methods and then we do pop up.
That adds to G.O. point
and your point.
Then it's added to the map.
So Colegio points object, create pop up object and pop up to dewpoint, add dewpoint to map.
As you can see, it's a simple hierarchy of objects.
If we execute that angle here.
Reloj
you see how there is in the pop up.
And now we can do dewpoint that get weather.
Don't forget to call it by using these parentheses.
Execute, reload, and now if you click on the marker, you'd expect to see the pop up with the list
of tuples, but that's not the case.
What you get is an empty pop up, because if you look at the help function or volume that pop up, I
have to import for volume again.
Go up, up and you'll see that this pop up gets.
The first arguments, it's an A.M. Original, is the name of the arguments currently assigned to none,
but each time you see that, it gets either a string or an element type.
So a string type or an element type, an element.
So it's a specific type that volume provides.
So just like we have a map pop up, there's also an element which allows you to provide XHTML, but
we were not thinking about that.
Now, basically, string is a most common type that this pop up gets as first argument.
So this is actually the value of the Amelle argument.
And what we are providing here is a list type.
Since this gets whether Method's returns, at least Botsford we can add to are in front of that to create
an ETR.
So a string object out of this list.
If you execute that, to create to generate the map again, everything is working fine.
As you can see, no errors reloads here.
And this time you see the list of tuples.
So it is actually a string, but it shows the information about those lists of the actual lists represented
as a string, and that's how it all works.
So since we use this popup object, that means we don't need to these.
Arguments here anymore, so you can delete that and that's two and the things will work the same because
because you can see that now we're not using the argument anymore here.
And I hope that is clear and I'll talk to you later again.
Sue.