function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
uuuu 

How to create map view in lightning

I have custom object with a field Geolocation type .
How can i create map view of that cities .
I have inserted longitude and latitude values for every city.
how i add it to page layout?
Danish HodaDanish Hoda
Hi Anita,
You can refer the sample code below:
CMP:--

<aura:attribute name="myMap" type="Map"/>
<aura:iteration items="{!v.myMap}" var="cus" indexVar="key">
            <tr>
                <td title="Account">
                    {!cus.key}<br/><br/>
                </td>
                <td title="Contacts">
                    <aura:iteration items="{!cus.value}" var="cs">
                        <tr>
                            {!cs.Name}
                        </tr>
                    </aura:iteration>
                </td>
            </tr>
        </aura:iteration>

JS:--

var custs = [];
for(var sk in data){
custs.push({value:data[sk], key:sk});
}
component.set("v.myMap", custs);

 
uuuu
Thank you Danish...but I want to create a vfpage and apex class
How to do it?
sachinarorasfsachinarorasf
Hi Anita,

Please follow the below links.

https://developer.salesforce.com/docs/component-library/bundle/lightning:map/example
https://developer.salesforce.com/docs/component-library/bundle/lightning:map/documentation
https://rajvakati.com/2018/09/26/creating-google-maps-with-lightningmap-component/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora