Search code examples
here-api

Map Image API - Region Resource - request URL too long


I want to get an image with an outlined region from the Map Image API Region Resource. I'm getting the coordinates for the region from the Geocoder API and hand these over to the Map Image API. If the number of coordinates I retrieve from the Geocoder API is relatively low everything is fine. But if there is a large number of coordinates the request URL gets too long for the request.

I already tried to use a POST request but without success and anyway this is not supported.

Is there a way to use the Map Image API Region Resource with a larger amount of coordinates?


Solution

  • Finally got it to work by using the Route Resource instead of Region Resource.

    The Route Resource is the only one that supports POST requests (and with that supports larger payloads) and has a feature to add polylines. So no filling possible for an region but fine for me.

    The funny thing is that the apiKey is not accepted in the payload for whatever reason so I have to send it as an URL parameter... Took me more than an hour to figure that out...

    Example:

        map_response = requests.post('https://image.maps.ls.hereapi.com/mia/1.6/route?apiKey='+apiKey, data = {'r':coords, 'lc': 'FFFF0000', 'h':850, 'w':1314})