Hybrid View

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    82
    Vote Rating
    0
    ronaldoneal is on a distinguished road

      0  

    Default Oreilly Map Demo Modification for Driving Directions

    Oreilly Map Demo Modification for Driving Directions


    Using the Oreilly map demo to map a location, I am trying to modify the Location.js in the app\view directory it to do driving directions to the location. The error is on this line: directionsRenderer.setMap(map);

    After running the following code, I receive the error message "Uncaught error: Invalid value for property <map>", [object] Object

    Ext.define('HCofC.view.Location', {


    extend: 'Ext.Container',
    requires: 'Ext.Map',


    xtype: 'location',


    config: {


    title: 'Location',
    iconCls: 'locate',


    layout: 'fit',


    items: [
    {
    docked: 'top',
    xtype: 'toolbar',
    title: 'Location'
    }
    ]
    },


    initialize: function() {

    var directionRenderer;
    var directionsService = new google.maps.DirectionsService();
    var map;

    var position = new google.maps.LatLng(HCofC.app.mapCenter[0], HCofC.app.mapCenter[1]),
    infoWindow = new google.maps.InfoWindow({ content: HCofC.app.mapText }),
    map, marker;


    this.callParent();


    map = this.add({
    xtype: 'map',
    mapOptions: {
    center: position,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    });


    directionsRenderer = new google.maps.DirectionsRenderer();
    directionsRenderer.setMap(map);

    marker = new google.maps.Marker({
    position: position,
    map: map.getMap(),
    visible: true
    });


    google.maps.event.addListener(marker, 'click', function() {
    infoWindow.open(map, marker);
    });
    }
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,121
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Just like when you add your marker you used map.getMap(), you need to use that reference as that is the google map instance. You are trying it on the ST2 map component.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    82
    Vote Rating
    0
    ronaldoneal is on a distinguished road

      0  

    Default


    It worked. You can close this one.

Thread Participants: 1

Tags for this Thread