Hi all,
Iām hoping to send out emails with links to static Google Maps showing the delivery areas for our paper rounds. However sadly the Maps-Areas module stores the coordinates as āLongitude, Latitude, Elevationā instead of the more conventional āLatitude, Longitudeā required by the Google API.
Instead of giving up, I dipped into the code, and found that with the following modification I could create a second field with the corrected format. This should allow me to pass this to a URL to generate the map. Hurray!
From row 219 of /modules/jjwg_Areas/views/view.area_edit_map.php
// Define polygon(s) coordinates as lng,lat,elv string and set to 'coordinates' field
$('#showData').click(function() {
$('#dataPanel').empty();
var myCoords = Array();
var myDataString = '';
var myDataString2 = '';
for (var i=0; i<myAreaPolygon.length; i++) {
var polygon = myAreaPolygon[i];
if (polygon != '') {
myCoords = polygon.getPath().getArray();
if (myCoords.length > 1) {
for (var j=0; j<myCoords.length; j++) {
var myCoord = myCoords[j];
// Return format: lng,lat,elv
// Reduce percision to 8 after decimal and trim zeros
var lng = myCoord.lng().toFixed(8).replace(/0+$/g, "");
var lat = myCoord.lat().toFixed(8).replace(/0+$/g, "");
myDataString += lng + ',' + lat + ',0 ';
myDataString2 += lat + ',' + lng + '|';
}
myDataString = myDataString.replace(/^\s+|\s+$/g,"");
myDataString2 = myDataString2.replace(/^\s+\s+$/g,"");
myDataString += "\n\n";
myDataString2 += "\n\n";
}
}
}
// Update Coordinates display
myDataString = myDataString.replace(/^[\s\n\r]+|[\s\n\r]+$/g,"");
$('#dataPanel').append(myDataString.replace(/[\n\r]/g,"<br />"));
// Update parent form 'coordinates' field
parent.document.getElementById('coordinates').value = myDataString;
parent.document.getElementById('latlngcoordinates_c').value = myDataString2;
});
However, Iām a complete n00b at this, so Iāve got a couple of queries:
To what extent is my modification āupgrade safeā? Do I need to do something special to ensure my changes arenāt overwritten later?
How come the text is overspilling its TextArea box?