Source

genmap / templates / marks / add.html

Full commit
{% extends "base.html"%}
{% load i18n %}

{%block extrahead%}
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={{gmaps_key}}" type="text/javascript"></script>

<script type="text/javascript">

	function smbtForm(){
		if( (!document.mform.latitude.value) | (!document.mform.longitude.value)){
			alert("{%trans "Please select a point on the map first"%}");
		}
		else{
			//Submit form
			document.mform.submit();
		}
	}

</script>
{%endblock%}

{%block outsideright%}
{%endblock %}
{% block content %}
<h1>{% trans "Add/edit your profile"%}</h1>
<div id="map" style="width: 926px; height: 350px"></div>
<div class="msg">{% trans "Click on the map to select your location first"%}</div>
{#<div id="amap" style="width: 300px; height: 200px"></div>#}

<p>
<div class="frm">
	<form action="." method="POST" enctype="multipart/form-data" name="mform" >
		{%csrf_token%}
		<table>
			<a name="forma"></a>
			{{nameform.as_table}}
			{{form.as_table}}
		</table>
		<br/>
		<button type="button" onclick="smbtForm();">{%trans "Submit"%}</button>
	</form>
</div>
</p>

<h2>{%trans "Other settings"%}</h2>

<ul>
    <li><a href="{% url openid-associations %}">{%trans "Change your OpenIDs"%}</a></li>
    <li><a href="{% url openid-password %}">{%trans "Change your Password"%}</a></li>
</ul>

{%endblock %}


{%block endjsblock %}
<script type="text/javascript">
	//<![CDATA[

if (GBrowserIsCompatible()) {

	var lastmarker;
	/*
	   var iwform = '<form action="#" onsubmit="process(this); return false">'
	   + 'Επιλέξτε το σημείο που θέλετε να προσθέσετε<br/>'
	   + '<input type="submit" value="Εδώ" />'
	   + '</form> '
	 */

	function createInputMarker(point,balloon) {
		var marker = new GMarker(point,{draggable:true, icon:G_START_ICON});
		marker.disableDragging();
		GEvent.addListener(marker, "click", function() {
				lastmarker = marker;
				marker.openInfoWindowHtml();
				});
		map.addOverlay(marker);

		lat = marker.getPoint().lat();
		lng = marker.getPoint().lng();
		//Update form elements
		document.mform.latitude.value = lat;
		document.mform.longitude.value = lng;
		//Fetch localname from JSON geonames
		/*
		var geoUrl = 'http://ws.geonames.org/findNearbyPlaceNameJSON?';
		geoUrl += 'lat='+lat+'&lng='+lng+'callback=?';
		jQuery.getJSON(geoUrl,function(json){
		if (typeof json.geonames != 'undefined' && json.geonames.length > 0) {
		}

		*/
		//Create message
		if(balloon){

		markertxt = 'Click <a href="#forma">here</a>'
			+ 'to continue';
		marker.openInfoWindowHtml(markertxt);
		}


		lastmarker=marker;

		return marker;
	}

	function createMarker(point,text) {
		var marker = new GMarker(point);
		GEvent.addListener(marker,"click", function() {
				marker.openInfoWindowHtml(text);
				});
		map.addOverlay(marker);
		return marker;
	}

	// == Display the map, with some controls and set the initial location
	var map = new GMap2(document.getElementById("map"),{draggableCursor:"default"});
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	{% if profile %}
	map.setCenter(new GLatLng({{profile.point.x}}, {{profile.point.y}}), 14, G_NORMAL_MAP);
	createInputMarker( new GLatLng({{profile.point.x}},{{profile.point.y}}) , false );

	{%else%}
	map.setCenter(new GLatLng(19.97335, -15.8203), 2, G_NORMAL_MAP);
	{%endif%}

	// == Listen for map click and add an input marker
	GEvent.addListener(map,"click",function(overlay,point){
			if (!overlay) {
			if(lastmarker){
			lastmarker.hide();
			}
			createInputMarker(point,true);
			}
			});
}
// display a warning if the browser was not compatible
else {
	alert("Sorry, the Google Maps API is not compatible with this browser");
}

//]]>
</script>
{%endblock %}

{%block inbody%} onunload="GUnload()" {%endblock%}