classygmaps icon indicating copy to clipboard operation
classygmaps copied to clipboard

"geocode" should be off if the query is lat/long

Open rickrich opened this issue 9 years ago • 8 comments

$ geo-firefox n42.57.245 w77.03.530 http://gokml.net/maps?f=q&source=s_q&hl=en&geocode=&q=N42+57.245+W77+03.530&ie=UTF8&t=h&ll=42.954083,-77.058833&z=19&output=classi

It puts the pin on a street address (9 Willard Ave), not on the target! Compare with:

$ geo-map -s0 n42.57.245 w77.03.530 http://www.rkkda.com/tmp/class-bug1.html

rickrich avatar Jun 03 '15 20:06 rickrich

If I set "q=http N42+57.245+W77+03.530" instead of "q=N42+57.245+W77+03.530" and I apply this patch:

$ diff -c index.html newmap.html 
*** index.html  2015-06-03 16:07:36.133169972 -0500
--- newmap.html 2015-06-03 16:10:03.356963102 -0500
***************
*** 248,253 ****
--- 248,257 ----
                                  var bits = value.split(',');
                                  mapCenter = new google.maps.LatLng(parseFloat(bits[0]),parseFloat(bits[1]));
                                map.setCenter(mapCenter);
+                               marker = new google.maps.Marker({
+                                   position: mapCenter,
+                                   map: map
+                               });
                          } else if (argname == "t") {
                                  if (value == "h") {mapType = google.maps.MapTypeId.HYBRID;}
                                  if (value == "r") {mapType = google.maps.MapTypeId.ROADMAP;}

then it works. Google has a way to differentiate lat/lon from geocode address, yours doesn't have this ability.

rickrich avatar Jun 03 '15 21:06 rickrich

This is kind of ironic, this is one of those issues always hounding Google about, every new maps product has this iss. And forgot to do anything about it here

If just send coordinates to the geocoder, it will reverse geocode, and then give the coordinates of that nearby found feature.

The search function needs to filter out coordinate entry and plot it directly. Easy enough to do, just easy to forget it needs doing.

(Your 'fix' I dont think is an apprioriate general fix, it will just put a marker where center the map with 'll' param. It might be ok in your specific case, but would confuse many other users)

barryhunter avatar Jun 08 '15 10:06 barryhunter

It would also be nice if there were a way to click-to-save the lat/lon of the cursor on the map.
Google does have this feature

There is a work-around - Use the cursor to position the point you want just at the top edge of the screen. Then slide the cursor up off the map, highlight the lat/lon, right-click and copy it.

JohnK625 avatar Jun 11 '15 17:06 JohnK625

@JohnK625, see the comment on https://github.com/barryhunter/classygmaps/issues/15

Can freeze the coordinate for copy/paste purposes

barryhunter avatar Jun 11 '15 17:06 barryhunter

Thanks, Barry - works great!

J.

On Thu, Jun 11, 2015 at 11:31 AM, barryhunter [email protected] wrote:

@JohnK625 https://github.com/JohnK625, see the comment on #15 https://github.com/barryhunter/classygmaps/issues/15

Can freeze the coordinate for copy/paste purposes

— Reply to this email directly or view it on GitHub https://github.com/barryhunter/classygmaps/issues/25#issuecomment-111215085 .

JohnK625 avatar Jun 11 '15 17:06 JohnK625

Implemented this in so far as supporting plain decimal degrees (ie 42.954083,-77.05883) - writing a full lat/long parser is too much work for a lazy sunday afternoon. Hopefully soon...

barryhunter avatar Jun 14 '15 16:06 barryhunter

I need DD MM.MMM for geocaching!

rickrich avatar Jun 14 '15 16:06 rickrich

Here's one way: function parse_location() { var address = document.getElementById("searchbox").value;

// Degree decimal -
//     N 45.123456 W 93.123456
var deg = /^([nNsS]) *(\d+)\.(\d+) +([eEwW]) *(\d+)\.(\d+) *$/;
var match = deg.exec(address);
if (match != null)
{
    var lat = parseFloat(match[2] + "." + match[3]); 
    var lon = parseFloat(match[5] + "." + match[6]); 
    if (match[1] == "s" || match[1] == "S") { lat = -lat };
    if (match[4] == "w" || match[4] == "W") { lon = -lon };
    map.setCenter(new google.maps.LatLng(lat, lon));
    return false;
}

// Degree and decimal minutes -
//     N 45 01.234 W 93 01.234
var degmin = /^([nNsS]) *(\d+) +(\d+)\.(\d+) +([eEwW]) *(\d+) +(\d+)\.(\d+) *$/;
match = degmin.exec(address);
if (match != null)
{
    var latmin = parseFloat(match[3] + "." + match[4]);
    var lat = parseInt(match[2]) + latmin / 60.0; 
    var lonmin = parseFloat(match[7] + "." + match[8]);
    var lon = parseInt(match[6]) + lonmin / 60.0; 
    if (match[1] == "s" || match[1] == "S") { lat = -lat };
    if (match[5] == "w" || match[5] == "W") { lon = -lon };
    map.setCenter(new google.maps.LatLng(lat, lon));
    return false;
}
...

`

rickrich avatar Jun 17 '15 11:06 rickrich