vendredi 30 septembre 2016

Change an icon using an 'if' statement in Google Maps

I'm writing a program for the oil and gas industry that allows you to see whether a pump-jack is on or off using a remote logic board at the site and relays the information via 4G internet. I'm trying to build it in a way that an icon on the map will be red or green depending of whether the alarm on the board is tripped. the file path can be reached via a static IP file path like for example:

http://ift.tt/2cPWJRL

this file path either gives a value of 1 or 0

how do i translate that value of 0 or 1 into an if statement that would change the icon depending on the value?

Here is my code for one of the icons:

 function initialize() {


        var map_canvas = document.getElementById('map_canvas');
        var map_options = {
          center: new google.maps.LatLng(50.242913, -111.195383),
          zoom: 14,
          mapTypeId: google.maps.MapTypeId.TERRAIN


        } 
        var map = new google.maps.Map(map_canvas, map_options);

        var point       =       new google.maps.LatLng(47.5, -100); 
        var derrick1    =       new google.maps.Marker ({
            position: new google.maps.LatLng(50.244915, -111.198540),    
            map: map,
            icon: 'on.png',
            size: new google.maps.Size(20, 32),
            title: '1' 

        })



        google.maps.event.addDomListener(window, 'load', initialize);
        

Aucun commentaire:

Enregistrer un commentaire