1 Reply Latest reply on Jun 7, 2010 8:51 AM by jatin4rise

    Unable to display marker in Google map

    jatin4rise

      I am able to see the map, but cannot observe the markers. I am not understanding, what exactly is the problem. Is it flex, mysql, php or xampp.?

       

      1. Following is my Map.mxml file

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx"
                     width="100%" height="100%"
                     xmlns:maps="com.google.maps.*">
         
        
          <fx:Script>
              <![CDATA[

       

                  import com.google.maps.LatLng;
                  import com.google.maps.MapEvent;
                  import com.google.maps.MapType;
                  import com.google.maps.controls.MapTypeControl;
                  import com.google.maps.controls.ZoomControl;
                  import com.google.maps.overlays.Marker;
                  import com.google.maps.overlays.MarkerOptions;
                 
                  import mx.collections.ArrayCollection;
                  import mx.rpc.events.ResultEvent;           
                        
                  [Embed(source="icon.png")]
                  private var ak:Class;
                             
                  private function map_mapevent_mapreadyHandler(event:MapEvent):void
                  {
                      map.setCenter(new LatLng(34.478788, 69.213867),8, MapType.PHYSICAL_MAP_TYPE);
                      map.addControl(new ZoomControl());
                      map.addControl(new MapTypeControl());
                      service.send();   
                  }
                 
                  private function service_resultHandler(e:ResultEvent):void
                  {
                      var list:ArrayCollection = e.result.map.loc;
                      for(var i:int = 0; i<list.length; i++){
                          //var bm:Bitmap = new ak() as Bitmap;
                          var m:Marker = new Marker(new LatLng(list[i].lat,list[i].lon),
                              new MarkerOptions({tooltip:list[i].name}));
                          map.addOverlay(m);
                      }
                  }
                 
              ]]>
          </fx:Script>

         <maps:Map width="100%" height="100%" id="map"
                    mapevent_mapready="map_mapevent_mapreadyHandler(event)"
                    key="ABQIAAAANweOXMI9Qcnf9FAwZ_BlfBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSQZUQd9P_MGDxmUP9GXyfkGKtF lA"/>
         
          <fx:Declarations>
             
              <s:HTTPService id="service" url="map.php" result="service_resultHandler(event)"/>   
             
          </fx:Declarations>
         
          <!-- UI components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
         
         
      </s:Application>

       

      2. map.php file

       

      <?PHP

       

      mysql_connect("localhost:3306", "root", "root");
      mysql_select_db("demo");

       

      $result = mysql_query("select * from maps");

       

      echo "<?xml version=\"1.0\" ?><map>";

       

      while($row = mysql_fetch_assoc($result)){
          echo "<loc><lat>" . $row["lat"] . "</lat>";
          echo "<lon>" . $row["lon"] . "</lon>";
          echo "<Name>" . $row["name"] . "</name></loc>";
      }

       

      echo "</map>";

       

      ?>

       

      3 Mysql runs on port : 3306 .

       

      Thanks for help