2011-12-17 13 views
0

Googleのjavascript APIを使用してアプリケーションを作成したときにこの同じ問題が発生しましたが、解決策は複数のマーカーを作成するコールバック関数で終了することでした。フレックスアクションスクリプト複数のマーカーマーカーがツールチップまたは緯線と一致しません

ランダムな数学関数を使用して複数のマーカーを作成する以外に、複数のカスタムマーカーを作成する例はありません。

GlobalVars私はmarkermanagerを使用して試してみましたが、それは私が最終的にはちょうどあきらめたいくつかの問題があり

...しかし、多くのaddressess、ラッツ、lngsなどに追いつくために、静的プロパティpublic varタイプを含むクラスでありますに。

retrieveLatLngAddress.addEventListener(GeocodingEvent.GEOCODING_SUCCESS, function(event:GeocodingEvent):void{ 

私は前にやっていたように私は、かなりのHTTPServiceを使用するよりも、アドレスでジオコーディングを始める場所ですから始めて、私は、より速く、他よりも戻ってくる1つのHTTPServiceの結果の問題に遭遇しました間違ったデータを間違ったマーカーに置きます。

明らかに、この方法で同じことをしているので、私は解決策を見つけられませんでした。

質問:どのように複数のマーカー情報を取得し、情報が返された順番ですべてのマーカーを保持することができますか。

は、ここでは、コードです:

  public function makeMultipleMarkers(destinationAllObj:Object):void { 
      removeRouteMarkers(); 
      myMarkers = []; 
      GlobalVars.myIcon = []; 
      GlobalVars.someAddress = []; 
      GlobalVars.sName = []; 

      markerMgr.clearMarkers(); 
      GlobalVars.destinationInc = 0; 

      retrieveLatLngAddress = new ClientGeocoder(); 
      retrieveLatLngAddress.addEventListener(GeocodingEvent.GEOCODING_SUCCESS, function(event:GeocodingEvent):void{ 
       var result:Placemark = GeocodingResponse(event.response).placemarks[0]; 
       var latLngStr:String = result.point.toString(); 
       GlobalVars.panoLatLng = latLngStr.split(','); 
       var deleteLeftParen:String = GlobalVars.panoLatLng[0]; 
       GlobalVars.panoLatLng[0] = deleteLeftParen.replace("(",""); 
       var deleteRightParen:String = GlobalVars.panoLatLng[1]; 
       GlobalVars.panoLatLng[1] = deleteRightParen.replace(")",""); 
       bounds = new LatLngBounds(); 


       var request:URLRequest = new URLRequest(GlobalVars.myIcon[GlobalVars.destinationInc]); 
       var imageLoader:Loader = new Loader(); 
       imageLoader.load(request); 
       imageLoader.name = String(GlobalVars.myIcon[GlobalVars.destinationInc]); 

       // Alert.show(GlobalVars.panoLatLng[0]); 
       var tmpLatLng:LatLng = new LatLng(GlobalVars.panoLatLng[0], GlobalVars.panoLatLng[1]); 
       someMarker = new Marker(tmpLatLng, new MarkerOptions({ 
        icon: imageLoader, 
        tooltip: destinationAllObj[GlobalVars.destinationInc].SNAME+', '+GlobalVars.someAddress[GlobalVars.destinationInc], 
        hasShadow: false 
       })); 

       someMarker.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent):void{ 
        var marker:Marker = event.target as Marker; 
        var markerContent:String = marker.getOptions().tooltip.toString(); 
        textInput.text = marker.getOptions().tooltip.toString(); 
        marker.openInfoWindow(new InfoWindowOptions({content: markerContent})); 

        sendSomeLatLngToSv(event.latLng); 

        var lastIndexOfDashStr:String = marker.getOptions().icon.name; 

        GlobalVars.iconObj = lastIndexOfDashStr; 
        var tmpArr:Array = new Array; 
        var tmpStr:String = event.currentTarget.getOptions().tooltip; 
        tmpArr = tmpStr.split(','); 
        GlobalVars.panoAddr[0] = tmpArr[1]; 
        GlobalVars.sName[0] = tmpArr[0]; 
       }); 

       myMarkers.push(someMarker); 
       googleMap.addOverlay(someMarker); 

       for each(someMarker in myMarkers) 
       { 
        var newLatLng:LatLng = someMarker.getLatLng(); 
        bounds.extend(newLatLng); 
       } 

       GlobalVars.destinationInc++; 

       if(GlobalVars.newDestObj.length == GlobalVars.destinationInc) 
       { 
        statusTxt.text = "Complete"; 
        googleMap.setCenter(bounds.getCenter(), (googleMap.getBoundsZoomLevel(bounds))-2, MapType.HYBRID_MAP_TYPE); 

        // markerMgr.addMarkers(myMarkers, 8, 16); 
        // markerMgr.refresh(); 
       } 
      }); 
      retrieveLatLngAddress.addEventListener(GeocodingEvent.GEOCODING_FAILURE, geocoderMarkersFailure); 


      for(GlobalVars.destinationCounter = 0; GlobalVars.destinationCounter < destinationAllObj.length; GlobalVars.destinationCounter++) 
      { 
       // Alert.show(destinationAllObj[GlobalVars.destinationCounter].ICON); 
       GlobalVars.someAddress[GlobalVars.destinationCounter] = destinationAllObj[GlobalVars.destinationCounter].SLOC; 
       GlobalVars.sName[GlobalVars.destinationCounter] = destinationAllObj[GlobalVars.destinationCounter].SNAME; 

       if(destinationAllObj[GlobalVars.destinationCounter].ICON == "") 
       { 
        GlobalVars.myIcon[GlobalVars.destinationCounter] = "images/school_32.png"; 
        // Alert.show(GlobalVars.destinationCounter+" "+GlobalVars.myIcon[GlobalVars.destinationCounter]); 
       } 
       else 
       { 
        GlobalVars.myIcon[GlobalVars.destinationCounter] = destinationAllObj[GlobalVars.destinationCounter].ICON; 
       } 

       statusTxt.text = "Processing data, please wait..."; 
      } 

      for(GlobalVars.destinationCounter = 0; GlobalVars.destinationCounter < destinationAllObj.length; GlobalVars.destinationCounter++) 
      { 
       var tempURL:String = "http://kronusproductions.com/mycarpaysme_ajax/php/google_lat_lng_flex_lausd.php?addr="+destinationAllObj[GlobalVars.destinationCounter].SLOC; 

       // loadMyXml(tempURL); 

       retrieveLatLngAddress.geocode(destinationAllObj[GlobalVars.destinationCounter].SLOC); 
       statusTxt.text = "Processing data, please wait..."; 
      } 
     } 

答えて

0

OK、私は適切にこの仕事をするために3つのことをやりました。

最初に、forループを1つだけ書きました。

第2に、3秒後にmakeMultipleMarkers関数を2回呼び出します。

第三に、私はまだ500のステータスコードを受信した場合、アイテムは地区にクリックされた後、私は500

 public function makeMultipleMarkers(destinationAllObj:Object):void { 
      myMarkers = []; 
      GlobalVars.myIcon = []; 
      GlobalVars.someAddress = []; 
      GlobalVars.sName = []; 
      GlobalVars.destinationInc = 0; 

      googleMap.getPaneManager().clearOverlays(); 

      bounds = new LatLngBounds(); 
      retrieveLatLngAddress = new ClientGeocoder(); 

      retrieveLatLngAddress.addEventListener(GeocodingEvent.GEOCODING_SUCCESS, function(event:GeocodingEvent):void{ 
       var result:Placemark = GeocodingResponse(event.response).placemarks[0]; 
       var latLngStr:String = result.point.toString(); 
       // GlobalVars.statusCode = event.status; 

       var request:URLRequest; 
       var imageLoader:Loader = new Loader(); 

       if(GlobalVars.destinationInc < destinationAllObj.length) 
       { 
        imageLoader.load((destinationAllObj[GlobalVars.destinationInc].ICON == "")? request = new URLRequest("images/school_32.png") : request = new URLRequest(destinationAllObj[GlobalVars.destinationInc].ICON)); 
        imageLoader.name = String(destinationAllObj[GlobalVars.destinationInc].ICON); 

        someMarker = new Marker(result.point, new MarkerOptions({ 
         icon: imageLoader, 
         tooltip: destinationAllObj[GlobalVars.destinationInc].SNAME+', '+destinationAllObj[GlobalVars.destinationInc].SLOC, 
         hasShadow: false 
        })); 

        someMarker.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent):void{ 
         directionsSteps.removeAll(); 
         var marker:Marker = event.target as Marker; 
         var markerContent:String = marker.getOptions().tooltip.toString(); 
         var firstComma:Number = markerContent.indexOf(","); 
         textInput.text = markerContent.substr((firstComma+2),markerContent.length); 
         var tempInfoWinOpts:InfoWindowOptions = new InfoWindowOptions({ 
          content: markerContent, 
          width: 450 
         }); 
         marker.openInfoWindow(tempInfoWinOpts); 

         sendSomeLatLngToSv(event.latLng); 

         var lastIndexOfDashStr:String = marker.getOptions().icon.name; 

         GlobalVars.iconObj = lastIndexOfDashStr; 
         var tmpArr:Array = new Array; 
         var tmpStr:String = event.currentTarget.getOptions().tooltip; 
         tmpArr = tmpStr.split(','); 
         GlobalVars.panoAddr[0] = tmpArr[1]; 
         GlobalVars.sName[0] = tmpArr[0]; 
        }); 

        googleMap.addOverlay(someMarker); 
        myMarkers.push(someMarker); 
        GlobalVars.destinationInc++; 
       } 

       for each(someMarker in myMarkers) 
       { 
        var newLatLng:LatLng = someMarker.getLatLng(); 
        bounds.extend(newLatLng); 
       } 

       if(destinationAllObj.length == GlobalVars.destinationInc) 
       { 
        statusTxt.text = "Complete"; 
        var tempNum:Number = googleMap.getBoundsZoomLevel(bounds); 
        googleMap.setCenter(bounds.getCenter(), (tempNum), MapType.HYBRID_MAP_TYPE); 
       } 

      }); 
      retrieveLatLngAddress.addEventListener(GeocodingEvent.GEOCODING_FAILURE, geocoderMarkersFailure); 

      for(GlobalVars.destinationCounter = 0; GlobalVars.destinationCounter < destinationAllObj.length; GlobalVars.destinationCounter++) 
      { 
       statusTxt.text = "Processing data, please wait..."; 
       retrieveLatLngAddress.geocode(destinationAllObj[GlobalVars.destinationCounter].SLOC); 
      } 
     } 

のステータスコードを受信しないまで、私はGoogleにリクエストを送信3秒待ってから関数をもう一度呼び出します。 DataGridのリフレッシュに似た関数。

  public function selectedItemChanged(event:ListEvent):void 
     { 
      this.parentDocument.flexGoogleMap.directionsSteps.removeAll(); 
      tempId = event.currentTarget.selectedItem.district_id; 
      this.parentDocument.passIdToRemoteGetSchoolsLocations(tempId); 
      setTimeout(mTimeOut, 3000); 
     } 

     public function mTimeOut():void{ 
      this.parentDocument.passIdToRemoteGetSchoolsLocations(tempId) 
     } 

ステータスコード500が返された場合。

  public function geocoderMarkersFailure(event:GeocodingEvent):void 
     { 
      var result:Number = event.status; 
      statusTxt.text = "Error: "+result+" processing address, re-processing, please wait 10-25 seconds..."; 
      GlobalVars.statusCode = result; 
      if(GlobalVars.statusCode == 500) 
      { 
       setTimeout(statusFiveHundred, 10000); 
       GlobalVars.statusCode = 0; 
      } 
     } 

      public function statusFiveHundred():void{ 
      this.parentDocument.passAllDestinations(); 
     } 

this.parentDocument.passAllDestinations()は、とりわけmakeMultipleMarkersを呼び出します。

はここでアプリへのURLです - まだテスト段階では:私の上司はロサンゼルスのすべての学校にドライブする必要がないようにenter link description here

はところで、このアプリを作りました。この方法で、彼は特定の学校区域をクリックし、続いて主要道路(高速道路、3車線または2車線)の隣の学校を選択し、学校がその特定の近くに広告を配置できるかどうかを決定し、そこからの学校。

もう1つの理由は、なぜですか。bin-releaseフォルダのswfファイルは動作しませんが、bin-debugの.swfファイルは動作しますか?

関連する問題