Skip to main content
Known Participant
December 2, 2014
Answered

Mapquest API AS3 - Points of Interest

  • December 2, 2014
  • 1 reply
  • 4124 views

Hey everyone,

I'm a new as3 student taking my first steps foward into a map-based tourism app.

I'm using the MapQuest API for as3, it's the first time I'm using an api and so far I've made the basic AS3 Map and the MouseWheel ZoomControl from here.

At the moment I'm trying to use the 'Easy POIl' from the link I left above but I've no idea how to get the code right, since it looks like xml and I'm working with AS3 on Flash Pro CC.

Can anybody help me?

Thanks a lot everyone, best regards.

Here's my code so far:

package {

//IMPORTS

    import flash.display.Sprite;

    import flash.display.StageScaleMode;

            import com.mapquest.tilemap.*

  import com.mapquest.tilemap.pois.*

            import com.mapquest.tilemap.controls.inputdevice.*;

            import com.mapquest.tilemap.controls.shadymeadow.*;

            import com.mapquest.LatLng;

  import mx.controls.*;

  public class AS3Map extends Sprite {

  var zs:ZoomSettings;

  var map:TileMap

  var myPoi:Poi;

//MAP

      public function AS3Map():void {

        //turn scaling off

        this.stage.scaleMode = StageScaleMode.NO_SCALE;

        //create a new TileMap object, passing your platform key

        map = new TileMap("Fmjtd%7Cluurn96rnl%2Cra%3Do5-9w80lr");

        //set the size of the map

        map.size = new Size(stage.stageWidth, stage.stageHeight);

        //add the map to the sprite

        addChild(map);

  addMapCenterF();

  addControlsF();}

//ZOOM

  private function addMapCenterF():void{

  //set the map center

  map.setCenter(new LatLng(41.156168845136705,-8.628559112548828),12);}

  private function addControlsF():void{

  //add a control to the map

  map.addControl(new SMLargeZoomControl());

    //make a zoomSettings object

    this.zs = new ZoomSettings();

    this.zs.animate = true;

    //CODIGO COM ERRO: this.zs.easeFunction = mx.effects.easing.Linear.easeInOut;

    //add the mousewheelzoomcontrol to the map

    map.addControl(new MouseWheelZoomControl());}

 

  }

  }

This topic has been closed for replies.
Correct answer kglad

package {

//IMPORTS

    import flash.display.Sprite;

    import flash.display.StageScaleMode;

            import com.mapquest.tilemap.*

  import com.mapquest.tilemap.pois.*

            import com.mapquest.tilemap.controls.inputdevice.*;

            import com.mapquest.tilemap.controls.shadymeadow.*;

            import com.mapquest.LatLng;

  import mx.controls.*;

  public class AS3Map extends Sprite {

  var zs:ZoomSettings;

  var map:TileMap

  var poi:Poi;

//MAP

      public function AS3Map():void {

        //turn scaling off

        this.stage.scaleMode = StageScaleMode.NO_SCALE;

        //create a new TileMap object, passing your platform key

        map = new TileMap("Fmjtd%7Cluurn96rnl%2Cra%3Do5-9w80lr");

        //set the size of the map

        map.size = new Size(stage.stageWidth, stage.stageHeight);

        //add the map to the sprite

        addChild(map);

  addMapCenterF();

  addControlsF()

addPOIF();

;}

//ZOOM

  private function addMapCenterF():void{

  //set the map center

  map.setCenter(new LatLng(41.156168845136705,-8.628559112548828),12);}

  private function addControlsF():void{

  //add a control to the map

  map.addControl(new SMLargeZoomControl());

    //make a zoomSettings object

    this.zs = new ZoomSettings();

    this.zs.animate = true;

    //CODIGO COM ERRO: this.zs.easeFunction = mx.effects.easing.Linear.easeInOut;

    //add the mousewheelzoomcontrol to the map

    map.addControl(new MouseWheelZoomControl());

}

private function addPOIF():void{

// or add it elsewhere

poi = new Poi(map.center);

map.addShape(poi);

}

}

  }

1 reply

kglad
kgladCorrect answer
Adobe Expert
December 2, 2014

package {

//IMPORTS

    import flash.display.Sprite;

    import flash.display.StageScaleMode;

            import com.mapquest.tilemap.*

  import com.mapquest.tilemap.pois.*

            import com.mapquest.tilemap.controls.inputdevice.*;

            import com.mapquest.tilemap.controls.shadymeadow.*;

            import com.mapquest.LatLng;

  import mx.controls.*;

  public class AS3Map extends Sprite {

  var zs:ZoomSettings;

  var map:TileMap

  var poi:Poi;

//MAP

      public function AS3Map():void {

        //turn scaling off

        this.stage.scaleMode = StageScaleMode.NO_SCALE;

        //create a new TileMap object, passing your platform key

        map = new TileMap("Fmjtd%7Cluurn96rnl%2Cra%3Do5-9w80lr");

        //set the size of the map

        map.size = new Size(stage.stageWidth, stage.stageHeight);

        //add the map to the sprite

        addChild(map);

  addMapCenterF();

  addControlsF()

addPOIF();

;}

//ZOOM

  private function addMapCenterF():void{

  //set the map center

  map.setCenter(new LatLng(41.156168845136705,-8.628559112548828),12);}

  private function addControlsF():void{

  //add a control to the map

  map.addControl(new SMLargeZoomControl());

    //make a zoomSettings object

    this.zs = new ZoomSettings();

    this.zs.animate = true;

    //CODIGO COM ERRO: this.zs.easeFunction = mx.effects.easing.Linear.easeInOut;

    //add the mousewheelzoomcontrol to the map

    map.addControl(new MouseWheelZoomControl());

}

private function addPOIF():void{

// or add it elsewhere

poi = new Poi(map.center);

map.addShape(poi);

}

}

  }

GusMaia00Author
Known Participant
December 3, 2014

Thanks a lot, it worked 1st try

Btw, do u have idea how can I say where to place the points of interest and how can I make more than 1?

kglad
Adobe Expert
December 3, 2014

just create new poi's using the lat/long as the Poi argument and add them toyour map using addshape