Sobi2
FAQ
Google Maps & Way Search
How to fetch geo coordinates in add/edit entry form (by map) |
Located in Google Maps & Way Search Tagged with Google Map, fetch coordinates, geo |
|
|
|
| Written by Sigrid Suski |
| Last updated on Friday, 16 April 2010 |
Fetching Geographical Coordinates by address in the Add/Edit Entry form of Sobi2.Works with Sobi2 versions since RC 2.7.2 Requirements:
Instructions:
<script src="http://maps.google.com/maps?file=api&v=1&key={googleApiKey}" type="text/javascript"></script>; <div id="map" style="width: 400px; height: 300px"></div> <script type="text/javascript"> //<![CDATA[ var start_latitude = "52.4777619318499"; var start_longitude = "-1.89788818359375"; var zoomlevel_add = 11; var zoomlevel_edit = 3; var map = new GMap(document.getElementById("map")); map.addControl(new GSmallMapControl()); var latitude = document.getElementById('field_latitude').value; if (latitude == "") latitude = start_latitude; var longitude = document.getElementById('field_longitude').value; if (longitude == "") longitude = start_longitude; if (latitude == start_latitude) zoomlevel = zoomlevel_add; else zoomlevel = zoomlevel_edit; // center and zoom to the lat/long in the form map.centerAndZoom(new GPoint(longitude,latitude), zoomlevel); GEvent.addListener(map, 'click', function(overlay, point) { if (point) { document.getElementById('field_latitude').value = point.y; document.getElementById('field_longitude').value = point.x; } } ); //]]> </script>
If you want to use the map inside sobiTabs, additionally enter the following small script at the end of the Entry Form Template. Replace myOwnPane with the pane name you use in your template. Description of sobiTabs <script> myPaneMap = document.getElementById('myOwnPane'); oldmyPaneMap = myPaneMap.onclick; myPaneMap.onclick = function(){ map.checkResize(); if (oldmyPaneMap) oldmyPaneMap(); } </script>
|
| Published on Tuesday, 29 January 2008. Visited 20547 times. |
| < Prev | Next > |
|---|
| Powered by Sigsiu.NET | ![]() |
Visitors: