繁体   English   中英

是否可以在ASP.NET中提供其他Google API密钥?Google Maps Application?

[英]It is possible to give different Google API Key in ASP.NET Google maps Application?

  I am using googlemaps.subgurim.net in my application,it is possible to set different GOOGLE API KEY to different users based on their logins.
              web.config:        
            <add key="googlemaps.subgurim.net" value="xxxxxxxxx"/>       
            .aspx:        
            <cc1:GMap ID="GMap1" runat="server" Height="805px" Width="800px" />       
            .aspx.cs:        
            string sMapKey = ConfigurationManager.AppSettings["googlemaps.subgurim.net"];
            GeoCode objAddress = new GeoCode();          
            objAddress=Map.geoCodeRequest(newGLatLng(Convert.ToDouble(status.Rows[0][0]),Convert.ToDouble(status.Rows[0][1])), sMapKey);
                                    StringBuilder sb = new StringBuilder();
                                    if (objAddress.valid)
                                    {
                                        sb.Append(objAddress.Placemark.address.ToString());
                                        lbladd.Text = sb.ToString();
                                    }    

我在应用程序中使用googlemaps.subgurim.net,可以根据不同的用户登录名将其设置为不同的GOOGLE API KEY。

是的。 您将需要在其用户记录中保留其API密钥,例如在数据库中,然后在Api脚本中只需切换变量

网络表格

<script type="text/javascript"
  src="https://maps.googleapis.com/maps/api/js?key=<%=User.ApiKey%>&sensor=SET_TO_TRUE_OR_FALSE">
</script>

MVC

<script type="text/javascript"
  src="https://maps.googleapis.com/maps/api/js?key=@Model.UserApiKey&sensor=SET_TO_TRUE_OR_FALSE">
</script>

在Getter中值得一提的是,如果他们的APi密钥为null,则请使用默认值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM