AngularJS和地图API:停止提示计算机的位置 [英] AngularJS and Maps API: stop prompting for computer's location

查看:78
本文介绍了AngularJS和地图API:停止提示计算机的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了web应用程序,我在其中添加了地图和自定义标记具有以下角度循环:

I created my web application, in which I added a map and custom markers with the following Angular loop:

<map data-ng-model="mymap" zoom="4" center="[38.50, -95.00]" style="heigth:375px">
    <div ng-repeat="item in list">
    <marker position="[{{item.coordinates}}]" icon="./images/icon.png" 
                                            on-click="showInfoWindow('mbar')" />
        <info-window id="mbar" >
        <div>{{item.name}}</div>
        <div class="getdirections">
           <a ng-href="http://maps.google.com/?daddr={{item.coordinates}}">Map</a>
        </div>
        </info-window>

这部分工作正常,并且浏览器不问授权收集计算机的位置。
在同一网站的不同页面,我再次显示与此简单code自定义标记的地图:

This part works correctly and the browser does not ask the authorization to collect the computer's location. On a different page of the same website, I again show a map with custom marker with this simpler code:

<map data-ng-model="mymapdetail" zoom="11" center="{{selectedItem.coordinates}}">
    <marker position="{{selectedItem.coordinates}}" icon="./images/icon.png" />     

在此第二页,当我打开它,所有的浏览器检测到我要求计算机的位置。如果我不回答这个问题,我的自定义标记正确显示。只要我的回答是,无论共享或没有我的位置,标记消失。我需要清除缓存再次显示标记。没有错误出现在控制台。

In this second page, when I open it, all browsers detects that I am asking for computer's location. If I don't answer to the question, my custom marker is correctly shown. As soon as I answer, regardless of sharing or not my position, the marker disappears. I need to clear the cache to show the marker again. No errors appear in the console.

在哪里的问题?

推荐答案

<击>我似乎找到了问题:
首先片段:

It seems I found the issue: First snippet:

 <marker position="[{{item.coordinates}}]" ...

第二个片段:

<marker position="{{selectedItem.coordinates}}"

方括号缺失。 <击>对于一些原因,即使该标记被正确显示和地图正确地居中,则语法要求[]周围的坐标。也许,不把它们触发到客户端的请求,以设置标记重新presenting当前用户的位置。
添加支架似乎解决这​​个问题,并geolocalization显示不出来了。

添加方括号中是不是一个解决方案。即使将它们添加解决问题,它实际上会导致一个新的:重新加载页面后标记消失。拆除方括号发送回的提示,但至少标记正确显示。在第一页中,去除括号不会引起任何错误。

Adding square brackets is not a solution. Even though adding them resolves the issue, it actually causes a new one: the marker disappears after reloading the page. Removing the square brackets sends back to the prompt, but at least markers are correctly shown. In the first page, removing the brackets does not cause any error.

这篇关于AngularJS和地图API:停止提示计算机的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆