Javascript 如何使用Ionic本地地理定位在Ionic 2中显示当前位置标记
我正在使用爱奥尼亚2,我想制作地理定位应用程序。这是我用Ionic Native Geolocation显示当前位置标记的代码:Javascript 如何使用Ionic本地地理定位在Ionic 2中显示当前位置标记,javascript,android,google-maps-api-3,ionic-framework,geolocation,Javascript,Android,Google Maps Api 3,Ionic Framework,Geolocation,我正在使用爱奥尼亚2,我想制作地理定位应用程序。这是我用Ionic Native Geolocation显示当前位置标记的代码: let watch=this.geolocation.watchPosition(); 观看。订阅((数据)=>{ //数据可以是一组坐标,也可以是一个错误(如果发生错误)。 让pos=new google.maps.LatLng( data.coords.latitude, data.coords.longitude ); 让marker=new google.ma
let watch=this.geolocation.watchPosition();
观看。订阅((数据)=>{
//数据可以是一组坐标,也可以是一个错误(如果发生错误)。
让pos=new google.maps.LatLng(
data.coords.latitude,
data.coords.longitude
);
让marker=new google.maps.marker({
职位:pos
//图标:“assets/icon/marker2.png”
});
marker.setMap(map);
地图设置中心(pos);
marker.addListener('click',function()){
infowindow.setContent(“您的位置”);
信息窗口。打开(地图、标记);
});
当我在浏览器中运行时,会显示标记,但当我在android设备中运行时,不会显示标记。。。。
请问我该怎么办
抱歉,英语不好。在android上运行时,您有任何日志错误吗?没有,代码运行良好。这让我很困惑重新安装plugini已经完成了,但仍然无法工作。您得到了解决方案吗?…请分享您的解决方案在android上运行时有任何日志错误吗?没有,代码运行良好。这让我很困惑重新安装安装plugini已经完成了,但是仍然没有工作。你得到了你的解决方案吗?…请分享你的解决方案
let watch = this.geolocation.watchPosition();
watch.subscribe((data) => {
// data can be a set of coordinates, or an error (if an error occurred).
let pos = new google.maps.LatLng(
data.coords.latitude,
data.coords.longitude
);
let marker = new google.maps.Marker({
position: pos
// icon: 'assets/icon/marker2.png'
});
marker.setMap(map);
map.setCenter(pos);
marker.addListener('click', function() {
infowindow.setContent('<b>Your Location</b>');
infowindow.open(map, marker);
});