my initial code just generates 1 place name at a time instead of forming a
stack of the names i have entered
def high():
return locals()
def index():
if request.vars['place_name'] is not None:
loc_list = [request.vars['place_name']]
else:
loc_list = []
map_string = generate_map(loc_list)
return dict(map_string=map_string)
def generate_map(location_list):
map_str = """<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 500px;
width: 500px;
margin: 0px;
padding: 0px
}
</style>
</head>
<body>
<div id="map" style="width:750px; height:450px; border: 2px solid
#3872ac;"></div>
<script type="text/javascript">
var locations = ["""
for l in location_list:
map_str += """['%s','%s','abc'],""" % (l,l)
map_str += """];
var geocoder;
var map;
var bounds = new google.maps.LatLngBounds();
function initialize() {
map = new google.maps.Map(
document.getElementById("map"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 1,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
geocoder = new google.maps.Geocoder();
for (i = 0; i < locations.length; i++) {
geocodeAddress(locations, i);
}
}
google.maps.event.addDomListener(window, "load", initialize);
function geocodeAddress(locations, i) {
var title = locations[i][0];
var address = locations[i][1];
var url = locations[i][2];
geocoder.geocode({
'address': locations[i][1]
},
function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var marker = new google.maps.Marker({
// icon: 'http://maps.google.com/mapfiles/ms/icons/blue.png',
map: map,
position: results[0].geometry.location,
title: title,
animation: google.maps.Animation.DROP,
address: address,
url: url
})
infoWindow(marker, map, title, address, url);
bounds.extend(marker.getPosition());
map.fitBounds(bounds);
} else {
alert("geocode of " + address + " failed:" + status);
}
});
}
function infoWindow(marker, map, title, address, url) {
google.maps.event.addListener(marker, 'click', function () {
var html = "<div><h3>" + title + "</h3><p>" + address +
"<br></div><a href= #" + url + "'>View location</a></p></div>";
iw = new google.maps.InfoWindow({
content: html,
maxWidth: 350
});
iw.open(map, marker);
});
}
function createMarker(results) {
var marker = new google.maps.Marker({
// icon: 'http://maps.google.com/mapfiles/ms/icons/blue.png',
map: map,
position: results[0].geometry.location,
title: title,
animation: google.maps.Animation.DROP,
address: address,
url: url
})
bounds.extend(marker.getPosition());
map.fitBounds(bounds);
infoWindow(marker, map, title, address, url);
return marker;
}
</script>
</body>
</html>"""
return map_str
On Tue, Jun 28, 2016 at 12:05 PM, Suchismita Debnath <[email protected]
> wrote:
> if i want to create an app that shows the list of place names that i have
> entered, in a map . how do i do it in web2py?
>
> On Mon, Jun 27, 2016 at 4:43 PM, Marlysson Silva <[email protected]>
> wrote:
>
>> Explain better your problem..
>> The names of places are in a form of google maps or in a field of your
>> form?
>>
>> Em domingo, 26 de junho de 2016 08:25:40 UTC-3, Suchismita Debnath
>> escreveu:
>>>
>>> how do i update name of places and show them in google maps using web2py
>>> and python?
>>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.