perfahlen / AzureMapsRestServices

.Net 5 library to access AzureMaps Services
MIT License
27 stars 19 forks source link

Pass response byte[] from GetMapTile to AzureMap Control SDK #9

Closed stukarudel closed 5 years ago

stukarudel commented 5 years ago

Hi! Integrating with this NuGet package and love what you have done here. Do you know how to pass the byte[] result of GetMapTile() to the Azure Map Control WebSDK? I would like to call the Azure Map endpoint from my API and then pass the byte array to the JavaScript for rendering. I was hoping for an easy method on the constructor, but I don't see one:

map = new atlas.Map('myMap',  //byte array result from api here);
rbrundritt commented 5 years ago

Why would you want to do this? The GetMapTile method has the image data for a map tile. Where as the Azure Maps Web SDK is an interactive map control which directly accesses the Azure Maps tiles. There is no need to grab the tiles server side and pass them down to the web SDK.

stukarudel commented 5 years ago

How would I show the image data for the map tile via JavaScript without the web sdk?

rbrundritt commented 5 years ago

The web SDK already uses the vector tiles for the base maps. There is no need to call the tile service directly as the web SDK will do that.

stukarudel commented 5 years ago

Yes, I've had success using the web SDK. I want to use your library so I can have my API handle the map functionality. I'm just not sure how to get the result from the REST call on the screen.

perfahlen commented 5 years ago

I am not sure what you are trying to achieve.

Here is the documentation https://docs.microsoft.com/en-us/rest/api/maps/render/getmaptile, either you get a pbf (which is a protobuf, probably a geojson so you can look at geobuf). Png files are much easier. You can basically convert the byte[] to an image. However, this library is intended to make it easier to access Azure Maps Rest Services from backend or from a mobile application for example.

rbrundritt commented 5 years ago

On StackOverflow you mentioned wanting to use Azure Active Directory (AAD). The Web SDK supports AAD already: https://docs.microsoft.com/en-us/azure/azure-maps/how-to-use-map-control

stukarudel commented 5 years ago

Thank you for your quick responses. I am trying to build a store locator using this library, similar to the example using the web SDK here: https://docs.microsoft.com/en-us/azure/azure-maps/tutorial-create-store-locator . I am not using AAD, subscription key is fine. I intend for this to be a public facing application so I don't want to expose my subscription key the way the web sdk tutorial suggests. I would prefer to use this library to get the map, add the store data, add the zoom and location controls and then serve it back to my website. This way the subscription key is protected and not visible in browser tools.

rbrundritt commented 5 years ago

Ok, subscription keys are primarily for development as there is no way to secure them (some platforms do ip address/url referrer whitelisting but it is very easy to get around that). If you wan to secure your credentials, use Azure Active Directory. Since this is a public facing application, you can use AAD in anonymous mode. This is the only true way to lock down your credentials securely and still have your site publicly accessible. This is how most of the code samples are locked down in the documentation for Azure Maps.

Note, some information will be visible in browser tools, but not the sensitive information.

stukarudel commented 5 years ago

Do you have a code sample on how to integrate Azure AD in anonymous mode for Azure maps?

perfahlen commented 5 years ago

@stukarudel, no I don't. I will create a task for accessing the services with Azure AD