How does the integration of Google Maps into the web version work?

Asked

Viewed 34 times

0

Hello! My question may seem a little vague, but I didn’t know how to summarize my doubt in a few words. What I want to know is: how does Google Maps validate API_KEY and return the map in the web integration? Basically, the backend and frontend part I can turn around, but how does this feature of Google Maps that validates API_KEY, calls a callback and renders on screen?

I don’t know if you understand the question, but it’s not JS or backend. Basically, what resources/technologies would I need to know/study to be able to create something similar (thinking about technology, not product)? Has something to do with mime-type or something?

  • You want to create a service where users would need an API_KEY so they could use @Claudio Neto ?

  • What I need is basically to allow the user to integrate this way: <div id="test"></div>&#xA;<script src="MinhaUrlDoServiço?key=API_KEY"></script>&#xA;<script>&#xA; var testeApp = ObjectApp.RenderApplication($('#test'));&#xA;</script> Through my JS url, I would validate API_KEY and return the JS content, so my application could be rendered.

1 answer

0

I ran a test and I was able to solve it. Basically, that’s what I did:

C#

public HttpResponseMessage Index(string key)
{
    var response = new HttpResponseMessage();
    response.Content = new StringContent("function Console() { console.log('Funcionou - " + key + "'); }");
    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/javascript");
    return response;
}

HTML

<script src="http://localhost:41852/api/Scripts?key=123456"></script>
<script>
    Console();
</script>

Javascript returned by C# is integrated in my site and Function Console comes into existence, without giving any error in the console saying that Function Console was not defined.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.