Adding locations by LAT/LONG

Hello,

So, I’m trying to add the chargers in Egypt as the current data is very outdated. I’m pulling the locations manually from Google Maps, I get a LAT/LONG location of each station that I want to directly navigate to on the website but it seems it’s not working? Is there a specific format I need to use? An example from Google Maps would be like this: 28°20’23.0"N 33°03’35.5"E

Our map location lookup only uses place names for search.

Funny, I was thinking it would be good to have this exact feature. So seeing Salem’s request I’ll go ahead and echo it.

In the web interface it would be nice to be able to drop (say) 40.15849, -88.2769 into the search bar and have the map center on that lat/lng.

It would also be nice to be able to drop (say) OCM-282508 and have it open the charger with that ID.

Both these capabilities would be helpful for folks like me and Salem who are working hard to improve the station data quality.

Btw, I installed OCM’s iphone app and was playing around with it and like it.

Salem: in Google maps you can hover the mouse at the location pointed to by the red arrow (see below). This copies the address into the clipboard which can then be dropped into the the search box within OCM’s map. Unfortunately OCM then centers on the address rather than the lat/lng of the charger. This works, but is a bit more cumbersome because then you’ll need to adjust the center of the map to the correct charger location before adding the charger. I’ve been doing that a lot, …

2 Likes

Oh that’s very nice and will make it much easier! Thank you for that.

Hopefully we can get the LAT,LONG also later on

Sure, these are fairly “easy” to add for anyone that codes JS/typescript, could be a good first issue for someone?

I guess I could look around and maybe find it without asking but. . .

Is the source available someplace like github? Do you have a test server/installation where any changes could be tested or would a developer have to install their own instance?

Hi @Calif_Ioniq5 the relevant app source code is here and can reasonably be built by an individual (you need a mapbox api token to get map tiles to load). Familiarity with JavaScript/typescript and npm is generally required:

I don’t think these suggestions would require any changes to the actual OCM system/API, just the map app.

  • on search input, instead of directly searching for places via the mapbox api, parse the input
  • if the input is an integer number or OCM-id, assume that’s an OCM ID and set the search parmeteres based on that
  • if the input is a comma separated pair of numbers , center the map on that lat/lng, the map reposition will then automatically trigger a search and move the blue center marker. Adding a new POI at that lat/lng would then just require the user to select the blue center marker. There is already some code for latitude/longitude in the query string that does this for embedded map views (e.g. so that a dealership could center on their own position).

You make your changes (just for these features) to your own copy, create a branch and push it to github, then create a pull request against the ocm-app repo and I review that.

1 Like

Okay, cool, really happy that this feature will be implemented. I have a few more requirement suggestions for the implementation.

  • The lat/lng comma is optional. I think non-coders are likely to not include the comma.
  • the lat/lng get range checked and ignored/(warning?) if out of range.
  • The following syntax which is the primary google syntax should be supported: 33°28’00.4"N 86°46’34.1"W
  • The following might be useful if using Javascript & regex

// Parses a string to see it is specifying a valid lat/lng
// Examples of acceptable formats:
// 45.4 -122.6
// 45.4, -122.6
// lat: 45.4, lng: -122.6
// When succesful, returns the point, otherwise null.
function ParseForLatLng(searchText) {

if (searchText == null)
    return null;

// Validate the format
let validation = searchText.match(/^\s*((lat|latitude)(:)?)?\s*((\-)?[0-9]+\.[0-9]+)\s*(,?)\s*((lng|lon|longitude)(:)?)?\s*((\-)?[0-9]+\.[0-9]+)\s*$/gi);
if (validation == null) {
    //console.log( LS(), 'Validation Failure: ' + searchText);
    return null;
}

// The format is validated.
// so just extract the two floating point numbers
let result = searchText.match(/((\-)?[0-9]+\.[0-9]+)+/g);
const latLngArray = ('' + result).split(",");

if (latLngArray.length != 2)
    return null;

// Validate the latitude bounds
let lat = TextToFloat(latLngArray[0]);
if (lat != AshMinMax(-90.0, lat, 90.0))
    return null;

// Validate the longitude bounds
let lng = TextToFloat(latLngArray[1]);
if (lng != AshMinMax(-180.0, lng, 180.0))
    return null;

// All's good, return the Lat/Lng object!
let pt = new google.maps.LatLng(lat, lng);
return pt;

}

@AndyK if you wrote the above you would be capable of updating our app.

Thank you for your kind words. Yes, I might be able to contribute. Currently my focus is to complete fixing data issues with the U.S. ‘travel’ charger network which I define as DCFC stations with 3 or more chargers. I’ve done a first pass on ~45 of our 50 states so far.

I really hope this eventually gets added, pinpointing the location in Egypt where Mapbox is just not good, is very hard to do correctly.

This has now been implement on the web version of the app at https://map.openchargemap.io

  • Go to a specific lat/long using any of:
    • 45.4 -122.6
    • 45.4, -122.6
    • lat: 45.4, lng: -122.6
  • Go to a specific Degrees Minutes Seconds, e.g.:
    • 33°28’00.4"N 86°46’34.1"W
    • 28°20’23.0"N 33°03’35.5"E
  • Open a specific POI by OCM ID
    • 282508
    • OCM-282508

These are not yet available in the published versions of the mobile app (android/ios).