Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs获取json在google地图中不起作用_Javascript_Php_Mysql_Angularjs_Json - Fatal编程技术网

Javascript Angularjs获取json在google地图中不起作用

Javascript Angularjs获取json在google地图中不起作用,javascript,php,mysql,angularjs,json,Javascript,Php,Mysql,Angularjs,Json,我想给你看地图上该地区的位置列表。通过下面的代码,我可以展示这一点,但我不知道如何从MySQL中提取数据。如何使用ajax.php更改下面$scope.names的部分 此html代码工作正常: var hotelApp=angular.module('hotelApp',[]) hotelApp.controller('ContentControler',函数($scope,$http){ var imageUrl=base_url+'marker.png'; 变量映射选项={ 缩放:4,

我想给你看地图上该地区的位置列表。通过下面的代码,我可以展示这一点,但我不知道如何从MySQL中提取数据。如何使用ajax.php更改下面$scope.names的部分

此html代码工作正常:

var hotelApp=angular.module('hotelApp',[])
hotelApp.controller('ContentControler',函数($scope,$http){
var imageUrl=base_url+'marker.png';
变量映射选项={
缩放:4,
中心:新google.maps.LatLng(40.0000,-98.0000),
mapTypeId:google.maps.mapTypeId.TERRAIN
}
$scope.location_name=“”;
$http.get('properties.php').success(函数(数据){
$scope.namesx=数据;
});
$scope.names=[{
项目名称:名称,
项目地址:“安逸街123号”,
道具价格:325.00,
道具区:25,
道具描述:“这是第一个地点。”,
拉脱维亚:43.7000,
长:-79.4000
}, {
道具名称:“位置2”,
项目地址:“安逸街456号”,
道具价格:114.00,
道具区:3,
道具描述:“这是第二个地点。”,
拉脱维亚:40.6700,
长:-73.9400
}, {
道具名称:“位置3”,
项目地址:“安逸街789号”,
道具价格:98.00,
道具区:4,
道具描述:“这是第三个地点。”,
纬度:41.8819,
长:-87.6278
}, {
道具名称:“位置4”,
项目地址:“安逸街1011号”,
道具价格:150.00,
道具区:1,
道具描述:“这是第四个地点。”,
拉脱维亚:34.0500,
长:-118.2500
}, {
道具名称:“位置5”,
项目地址:“安逸街1213号”,
道具价格:250.00,
道具区:7,
道具描述:“这是弗斯的位置。”,
拉脱维亚:36.0800,
长:-115.1522
}];
$scope.map=new google.maps.map(document.getElementById('map'),mapOptions);
$scope.markers=[];
var infoWindow=new google.maps.infoWindow({maxWidth:350});
var createMarker=函数(信息){
var marker=new google.maps.marker({
map:$scope.map,
位置:新google.maps.LatLng(info.lat,info.long),
标题:info.prop_Name,
丹尼斯:info.prop_Addr,
动画:google.maps.animation.DROP,
});
marker.content=''+'
  • '+info.prop_Desc+'
  • '+'
  • '+info.prop_Addr+'
  • '+'
  • '+info.prop_Price+'
  • '+'
  • '+info.prop_Dist+'
  • '+'; google.maps.event.addListener(标记,'click',函数(){ infoWindow.setContent(“”+marker.title+“”+marker.content); infoWindow.open($scope.map,marker); }); google.maps.event.addListener($scope.map,'click',function(){ infoWindow.close($scope.map,marker); }); $scope.markers.push(marker); google.maps.event.addListener(infoWindow,'domready',function(){ //对包装信息窗口底部的DIV的引用 var-iwOuter=$('.gm-style-iw'); /*因为这个div位于.gm div样式iw之前的位置。 *我们使用jQuery并创建一个iwBackground变量, *并使用.prev()利用了上一个div的现有引用.gm样式iw。 */ var iwBackground=iwOuter.prev(); //删除背景阴影DIV children(':nth child(2)').css({'display':'none'}); //删除白色背景DIV children(':nth child(4)').css({'display':'none'}); //将信息窗口115px向右移动。 css({左:'115px'}); //将箭头76px的阴影移到左边距。 children(':nth child(1)').attr('style',function(i,s){returns s+'left:76px!important;'}); //将箭头76px移到左边距。 children(':nth child(3)').attr('style',function(i,s){returns s+'left:76px!important;'}); //更改所需的尾部阴影颜色。 iwBackground.children(':nth child(3)').find('div').children().css({'box-shadow':'silver 0px 1px 6px','z-index':'1'}); //引用对关闭按钮元素进行分组的div。 var iwCloseBtn=iwOuter.next(); //将所需效果应用于关闭按钮 css({opacity:'1',right:'38px',top:'3px',border:'7px solid#48b5e9','border radius':'13px','box shadow':'05px#3990B9'}); //如果infowindow的内容未超过设置的最大高度,则删除渐变。 如果($('.iw content').height()<140){ $('.iw bottom gradient').css({display:'none'}); } //在mouseout事件后,API会自动对按钮应用0.7不透明度。此函数将此事件反转为所需的值。 iwCloseBtn.mouseout(函数(){ $(this.css({opacity:'1'}); }); }); } 对于(i=0;i<$scope.names.length;i++){ createMarker($scope.names[i]); } $scope.openInfoWindow=函数(e,selectedMarker){ e、 预防默认值(); google.maps.event.trigger(selectedMarker,'click'); } $scope.goster=函数(e,selectedMarker){ e、 预防默认值(); 选择Marker.setIcon(图像URL); 选择marker.setAnimation(google.maps.Animation.BOUNCE); } $scope.gizle=函数(e,selectedMarker){ e、 预防默认值(); selectedMarker.setIcon(空); selectedMarker.setAnimation(nul
    setTimeout(function () {
       $scope.$apply();
    });
    
    app.controller('TestCtrl', function ($scope, $http) {
        $scope.names = [];
    
        $scope.operation = function(data) {
            // operation data
        };
    
        $http.get('ajax.php').success(function(data) {
            $scope.names = data;
            for (i = 0; i < $scope.names.length; i++) {
                $scope.operation($scope.names[i]);
            }
        });
    });