| Index
» Projects
» phpMyEdit
» Forum
» Google maps geocoding inserts |
 |
marcool
Joined: 07 Oct 2008
Posts: 5
Posted: 2008-10-07 20:37
Back to top
Reply with quote
|
I'm looking for a way to insert geocoding results of a search with the google maps API into several fields...
I didn't start putting together an extension but I'm guessing it shouldn't be so complicated.
I'm planning to try modifying the jscalendar extension.
Did anyone do that already?
Any clue where to start?
Cheers,
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2008-10-08 12:37
Back to top
Reply with quote
|
Hi...could you explain in more detail what you are trying to do? I'm sure I can help (I wrote the mce_cal extension).
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2008-10-08 14:38
Back to top
Reply with quote
|
The integration into PME is easy, and I would just adapt the calendar implementation. The difficult bit is going to be creating a javascript function that creates the functionality.
So what you need to do is to create a javascript function to create the popup, with a number of arguments, including one which gives the id of the field that you want updated with the coordinates (actually there's nothing to stop you updating multiple fields). It might look something like:
| Code: |
google.map(
search : "parameters for map search",
oCoord : <field on form for coordinates>,
oCountry : <field on form for country>)
|
|
marcool
Joined: 07 Oct 2008
Posts: 5
Posted: 2008-10-08 18:13
Back to top
Reply with quote
|
hehe... that might help a lot...
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2008-10-08 21:48
Back to top
Reply with quote
|
Could you give a more complete example? ie. what does showLocation do?
|
marcool
Joined: 07 Oct 2008
Posts: 5
Posted: 2008-10-08 21:52
Back to top
Reply with quote
|
| Code: |
<script src="http://maps.google.com/maps?file=api&v=2.x&key=xxxxyour-key-herexxxxx" type="text/javascript">
</script>
<script type="text/javascript">
var map;
var geocoder;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(34, 0), 1);
geocoder = new GClientGeocoder();
}
// addAddressToMap() is called when the geocoder returns an
// answer. It adds a marker to the map with an open info window
// showing the nicely formatted version of the address and the country code.
function addAddressToMap(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode that address");
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(place.address + '<br>' +
'<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
}
}
// showLocation() is called when you click on the Search button
// in the form. It geocodes the address entered into the form
// and adds a marker to the map at that location.
function showLocation() {
var address = document.forms[0].q.value;
geocoder.getLocations(address, addAddressToMap);
}
// findLocation() is used to enter the sample addresses into the form.
function findLocation(address) {
document.forms[0].q.value = address;
showLocation();
}
</script>
<script type="text/javascript" src="jscal/calendar.js"></script>
<script type="text/javascript" src="jscal/lang/calendar-en.js"></script>
<script type="text/javascript" src="jscal/calendar-setup.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="jscal/calendar-system.css">
|
|
|
Post new topic
Reply to topic
|
|
|
|