小编and*_*sto的帖子

如何在PHP中获取JSON数据?

如何使用PHP从JSON对象获取数据?:

[
 {
  "name": "Anders",
 },
 {
  "name": "Chris",
 },
 {
  "name": "Peter",
 }
]
Run Code Online (Sandbox Code Playgroud)

这是我的PHP代码:

$url = 'http://urltotheapi';
$content = file_get_contents($url);
$json = json_decode($content, true);
Run Code Online (Sandbox Code Playgroud)

php api foreach json

6
推荐指数
1
解决办法
5万
查看次数

Google Maps Infowindow职位

我有这个代码的问题,当我点击一个标记我希望infowindow在该标记的位置打开.

当我点击每个标记时,它们都会在同一个位置打开.

码:

App.map = function (data, cb) {
  App.getData(App.config.LFMurl(), function (data) {
    App.processData(data, function(arr){      
    var mapOptions = {
      zoom: 12,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById('map-canvas'),
        mapOptions)

  if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = new google.maps.LatLng(position.coords.latitude,
                                       position.coords.longitude)

      var marker

      $.each(arr, function (index, item) {            
        marker = new google.maps.Marker({
          position: new google.maps.LatLng(item.lat, item.long),
          map: map,              
          animation: google.maps.Animation.DROP        
        })
        google.maps.event.addListener(marker, 'click', function(){                            
          var infowindow = new google.maps.InfoWindow({                
            map: map,
            position: new google.maps.LatLng(item.lat, item.long),                                
            content: item.title
          })
          infowindow.open(map, this)
          console.log(item.artist)              
        }) …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps infowindow google-maps-markers

5
推荐指数
1
解决办法
1万
查看次数