javascript - Marker image in google maps depending on column value -


i found script makes possible create markers in google maps. markers loaded database. part of script follows:

    //load markers xml file, check (map_process.php)         $.get("map_process.php", function (data) {             $(data).find("marker").each(function () {                   var name      = $(this).attr('name');                   var address   = '<p>'+ $(this).attr('address') +'</p>';                   var type      = $(this).attr('type');                   var door      = $(this).attr('door');                   var point     = new google.maps.latlng(parsefloat($(this).attr('lat')),parsefloat($(this).attr('lng')));                   create_marker(point, name, address, false, false, false, "http://www.example.com/marker/icons/a.png");             });         });  

i made possible select 3 'types' creating marker, example a, b , c. markers displayed a.png. wondering if possible make marker image depending on type. if type a, a.png, if b, b.png , if type c, c.png.

can me?

maybe if statements?

//load markers xml file, check (map_process.php)         $.get("map_process.php", function (data) {             $(data).find("marker").each(function () {                   var name      = $(this).attr('name');                   var address   = '<p>'+ $(this).attr('address') +'</p>';                   var type      = $(this).attr('type');                   var door      = $(this).attr('door');                   var point     = new google.maps.latlng(parsefloat($(this).attr('lat')),parsefloat($(this).attr('lng')));                if(type == "a"){                  create_marker(point, name, address, false, false, false, "http://www.example.com/marker/icons/a.png");                } else if(type ="b"){                  create_marker(point, name, address, false, false, false, "http://www.example.com/marker/icons/b.png");                }                        });         });  

just put if statement inside inside $.get , create_marker based on result


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -