Sunday, August 16, 2015

INTEGRATE MAPBOX WITH VISUALFORCE TO CREATE BEAUTIFUL MAP - Part III

In continuation with my previous two posts -
today, I will explain how you can fetch geographic data from Salesforce and accordingly show them in Salesforce.

To start with let me first create an object - Household where I can store geographic information. Below you can find the object details - 
Now the Visualforce page - Mapbox Click here

Now when you will open the page you will see the three locations plotted.

In this example, I am using apex:repeat to prepare the GeoJSON data. To understand what is GeoJSON data, below is what Wikipedia stating -

Once the GeoJSON data is ready, I am adding the same with featurelayer -

L.mapbox.featureLayer(geojson).addTo(map);

Finally, I am using the click event to show the Household name when user clicks on the points inside map. The code for that - 

//Show popup with information on mouse click
myLayer.on('click',function(e){
     e.layer.openPopup();
}); 

In my next post, I will explain how you can draw geographic areas inside map using Mapbox. Please provide your feedback. Thanks.

0 comments:

Post a Comment