Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

GoogleMap and Jet

User329142 -OracleSep 28 2016 — edited Sep 29 2016

Hi,

i'm creating a test application based on OracleJET QuickStartBasic. I'm made a base integration with googlemap based on http://blog.whitehorses.nl/2016/02/12/integrate-google-maps-in-oracle-jet/ and it work fine. The problem is that when i enter in the page for the first time, i have to select the city in order to show the map. My goal is to show the map automatically when i enter in the page. When i try to do it, i get the error Cannot read property 'firstChild' of null.

The javascript code is

define(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojselectcombobox'

], function(oj,ko,$) {

   

   

   

    function mapContentViewModel() {

        var self = this;

        var locations = [{name: "AM", lat: "52.37", lon: "4.89"},

            {name: "SF", lat: "37.77", lon: "-122.42"},

            {name: "TO", lat: "35.69", lon: "139.69"},

            {name: "NY", lat: "40.71", lon: "-74.01"},

            {name: "GE", lat: "44.41", lon: "8.85"}];

        self.SelectLocationValue = ko.observable();

        self.SelectLocationValue("AM");

        createMap(); //here where i call create map

     

        function createMap() {

           

           // console.log($(this).find('googleMap'));

            for (var g = 0; g < locations.length; g++) {

                if (String(self.SelectLocationValue()) == locations[g].name)

                {

                    var lat = locations[g].lat;

                    var lon = locations[g].lon;

                }

            }

            var map;

            var mapProp = {

                center: new google.maps.LatLng(lat, lon),

                zoom: 14,

                mapTypeId: google.maps.MapTypeId.ROADMAP

            };

       map = new google.maps.Map(document.getElementById("googleMap"), mapProp); //Here where i get error.;

        this.optionChangedHandler = function (event, data) {

        createMap()

The error is related with document.getElementById. Can you help me? Thanks in advance.

This post has been answered by John JB Brock-Oracle on Sep 29 2016
Jump to Answer
Comments
Post Details
Added on Sep 28 2016
2 comments
525 views