How to change map marker's icon?


#1

After an hour search on the internet, this forum is my last hope to get this problem solved. I wonder how can I change the map icon (some custom icon instead on circles)? Someone said that change something in the main.js, any hints for doing that would be appreciated.



#2

Hi,

The change you're asking about concerns changing the styling of the markers on the main map.


To make such a change, you'll need to create a new (or change the existing) styleMap (OpenLayers.StyleMap) for the Reports layers. The default style map for the markers is defined in media/js/timeline.js - lines 425 - 666.


Thanks.



#3

Thank you for your reply. I have altered the script to change to map markers.In line 429, I changed the following command:


'externalGraphic': "${icon}",


into


externalGraphic: "http://localhost/tunis/media/uploads/category_1_1314619832.png",


This change successfully changed the map markers in ALL CATEGORIES layer. However, it also changed the map markers in other sub-categories.


May I ask how can I simply use the category icons to be the map markers corresponding to the selected category layer?


Any hints would be deeply appreciated.



#4

To have the category icons be the map markers, disable cluster mode for the main map. You can can do this in the "Settings" section in the Admin console.


Using category icons/images in cluster mode is currently not available.



#5

Thank you again ekala.

I followed what you said:


1. turn off cluster mode

2. edit the categories and upload the icon/image


The category icon has been changed on the right. But the map markers have not been changed in the map.They are still circles.


Did I miss some steps to make it work?


Maybe my questions were confusing. Actually I would like to set the map markers to be the same with the category icon.Moreover, I would like to show different icons in the ALL Categories layer instead of red circles.


Hope that my questions won't be too annoying.


Any hints will be appreciated.



#6

The markers on the main map are generated by application/controllers/json.php


If you deployment is in cluster mode, the cluster() method is used, else index() is used. These are the methods you need to look at if you want to change the output GeoJSON.


Also, your MarkerStyle will have to pick the graphic from the GeoJSON instead of fixing it to a specific icon.



#7

Hi ekala,

I cant find the timeline.js file with this path media/js/timeline.js…Im using 2.7.4 ver of ushahidi…Any advice?Thanks