-1
我知道我的語法在這裏是不正確的,但我似乎無法找出正確的語法來創建基於範圍的不同顏色的標記。這就是我現在和我所有的標誌顯示綠色(blank_g.png)在基於範圍的Javascript中創建標記
function createMarker(point,info,map,mag) {
var colorMarker = "blank_g.png" //for mag < 4
if (mag >= 4.0 && mag < 5.0) {
colorMarker = "blank_b.png";
}
else if (mag >= 5.0 && mag < 6.0) {
colorMarker = "blank_p.png";
}
else if (mag >= 6.0 && mag < 7.0) {
colorMarker = "blank_y.png";
}
else if (mag >= 7.0 && mag < 8.0) {
colorMarker = "blank_o.png";
}
else if (mag >= 8.0) {
colorMarker = "blank_r.png";
}
哪裏/你如何創建的標誌,你怎麼調用這個函數? – 2014-11-05 21:17:57
提供給'mag'的createMarker函數的值是什麼?他們都低於4.0嗎?請提供[最小,完整,已測試和可讀的示例](http://stackoverflow.com/help/mcve) – geocodezip 2014-11-05 23:38:57
不存在一些介於4和5之間的值。腳本從此處提取數據:http:/ /earthquake.usgs.gov/earthquakes/map/#%7B%22feed%22%3A%221day_m25%22%2C%22search%22%3Anull%2C%22sort%22%3A%22newest%22%2C%22basemap%22 %3A%22grayscale%22%2C%22autoUpdate%22%3Atrue%2C%22restrictListToMap%22%3Atrue%2C%22timeZone%22%3A%22local%22%2C%22mapposition%22%3A%5B%5B-44.84029065139799%2C -219.0234375%5D%2C%5B81.2550322990594%2C-25.3125%5D%5D%2C%22overlays%22%3A%7B%22plates%22%3Atrue%7D%2C%22viewModes%22%3A%7B%22map%22 %3A實例%2C%22列表%22%3A實例%2C%22設置%22%3A實例%2C%22幫助%22%3A錯誤%7D%7D – niklas24 2014-11-06 00:05:19