# Directions/mapping API with waypoints



## Damonc (May 9, 2001)

Hi,
I'm just curious if anyone has any recommendations for a web-based mapping/directions API, something similar to Google Maps, but can have more than 23 waypoints per request. Something with at least 100 would be great.

I need the directions to be 'optimised' between the waypoints the way google maps does, I have looked at various bits of code to workaround the 23 waypoint limitation however nothing that I've found seem to be really reliable so it leaves me wondering if someone knows of a different service I could use.

Thanks in advance!


----------



## JiminSA (Dec 15, 2011)

I wonder if this workaround might help?


----------



## dvk01 (Dec 14, 2002)

Bing allow 25 waypoints https://msdn.microsoft.com/en-us/library/ff701717.aspx

I can't see anyone giving you more for free. But if there was need for it, I am sure either google or Bing would allow it for the appropriate cost
This seems to suggest it can be done but you have to pay for the access so it isn't free
https://social.msdn.microsoft.com/F...ime-to-calculate-route?forum=bingmapsservices


----------



## Damonc (May 9, 2001)

It doesn't really need to be free.. as long as its not oober expensive. I had a look at Google's paid services, they allow more API requests per 24 hours, but not anymore waypoints... I hadn't looked at bing's paid services tho (or *if* they actually had any).


----------



## Damonc (May 9, 2001)

JiminSA said:


> I wonder if this workaround might help?


Hi JimminSA - I had actually seen that page, however I didn't think (correct me if I'm wrong) that it did any waypoint optimisation and would just spit them out in the order it was fed..


----------



## Damonc (May 9, 2001)

OK I've found this: https://github.com/geirke/optimap they've got a working demo here: http://gebweb.net/optimap/

does exactly what I'm after, supports up to 100 entries.. however from my own testing server, it doesn't actually draw a waypoint or any directions on the map, however it does jump to the correct location.. I'm not really that familiar with javascript files.. but I'm just looking in them to see if I need to put an API key in anywhere.


----------



## JiminSA (Dec 15, 2011)

I'm afraid that any javascript advice you may need will not be from me I'm probably less conversant with it than yourself ...


----------



## Damonc (May 9, 2001)

JiminSA said:


> I'm afraid that any javascript advice you may need will not be from me I'm probably less conversant with it than yourself ...


All Good. I've never really done much with it, so basically no experience.. So I'll probably just use a bit of trial and error to see if I can get it to work 

I'm guessing there is just a linked file that isn't linked.


----------



## Damonc (May 9, 2001)

Got it sorted.. it was a matter of files not being linked..

However, JiminSA, I've got a question that you can probably answer, or at least offer advice on..

I've got a textbox that I'm using jquery to autocomplete from a mysql table.. I'd like to be able to have PHP validate when the form is submitted that the contents of that textbox match an entry from the autocomplete table. I'd use a good old drop-down box, but theres more than 500 entries in the autocomplete table..


----------



## JiminSA (Dec 15, 2011)

Ah! Maybe I can help there.
I would set up an array from the db and use in_array to detect your element. Something along these lines (not tested!) ...

```
<?php
// set up your array (first connect to your db) then ...
$sql = "SELECT your_element FROM YourTable";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    $el_array = array();
    while($row = $result->fetch_assoc())
    {
        $el_array[$row['your_element']] = $row['your_element'];
    }
}

function find($search)
{
    $found = false;
    if(in_array($search, $el_array))
    {
        $found = true;
    }
}

if(isset($_POST) && $_POST['search_element'] != "")
{
    $search = $_POST['search_element'];
    find($search);
    if($found)
    {
        // success
    }
    else
    {
        // failure
    }
}
?>
......
......

" >
```


----------



## Damonc (May 9, 2001)

Alright, cheers - I'll try it out and let you know how it goes


----------

