Sign in to follow this  
jbrack321

Dynamically Apply Markers

Recommended Posts

Hello,

 

I am very new to Fusion Maps and hope someone can assist. I would like to dynamically apply makers based on data base values. Through the tutorials I see that I can apply definitions of the markers only and then apply <application> to call the marker.

 

I am using the dataXML method and PHP.

 

Can someone provide an example of this for me? I cannot get this to work.

 

Thanks,

 

lhardee

Edited by jbrack321

Share this post


Link to post
Share on other sites
Guest Sumedh

Greetings. smile.gif

 

For applying markers dynamically, you would need to add markers xml format in the dataXML,

 

Ref. Code;

 

$strxml .="<markers>";

$strxml .="<definition>";

$strxml .="<marker id='HO' x='140.09' y='165.19' label='Head Office' />";

$strxml .="<marker id='PF' x='553.37' y='182.25' label='Production Center' />";

$strxml .="<marker id='SA' x='447.04' y='106.57' label='Sales' />";

$strxml .="</definition>";

$strxml .="<application>";

$strxml .="<marker id='HO' shapeId='circle' />";

$strxml .=''<marker id='PF' shapeId='arc' />";

$strxml .="<marker id='SA' shapeId='trianngle' />";

$strxml .="</application>";

$strxml .="</markers>";

 

Also note that, you would need to define marker id's with the predefined id's in the database file.

 

Please refer the following links, for more information:

 

http://docs.fusionch...HPDB_USMap.html

 

http://docs.fusionch...s/MarkerOv.html

 

Hope this helps. smile.gif

 

Share this post


Link to post
Share on other sites

Hi Sumedh,

 

Thanks for your reply. I checked out your suggestions and cannot seem to find a solution. Below is an example of some markers I created. However I only want to call those markers if ($rs1['datap']= a certain value.

 

I cannot figure out what I am doing incorrectly to call the markers properly. Any help would be appreciated.

 

 

$strXML .= "<markers>";

$strXML .= "<shapes>";

 

$strXML .= "<shape id='myCustomShape' type='image' url='Resources/Google_Maps_Marker.png' labelPadding='12' />";

$strXML .= "</shapes>";

$strXML .= "<definition>";

 

$strXML .= "<marker id='1' x='709.31' y='69.94' label='example a' labelPos='top' />";

$strXML .= "<marker id='2' x='320.11' y='200.54' label='example b' labelPos='top' />";

 

$strXML .= "</definition>";

$strXML .= "<application>";

$strXML .= "<marker id='1' shapeId='myCustomShape' link='n-http%3a%2f%2example1webpage.php>";

$strXML .= "<marker id='2' shapeId='myCustomShape' link='n-http%3a%2f%2example2webpage.php' />";

$strXML .= "</application>";

$strXML .= "</markers>";

 

$strXML .= "<styles>";

$strXML .= "<definition>";

$strXML .= "<style name='markerAnim' type='animation' param='_y' start='0' duration='1.2' easing='bounce' />";

$strXML .= "</definition>";

$strXML .= "<application>";

$strXML .= "<apply toObject='MARKERS' styles='markerAnim' />";

$strXML .= "</application>";

$strXML .= "</styles>";

 

------------------------------------------------------------------------------------------------------

 

 

$strQuery = "select state, sum(datap) as datap from (select tracker.state, tracker.data datap from tracker union all select cable_intrusion.state, cable_intrusion.data datap from cable_intrusion union all select fibertesting.state, fibertesting.data datap from fibertesting) as datap group by state";

 

$result = mysql_query($strQuery) or die(mysql_error());

# Check if we've records to show

if ($result) {

# Iterate through each record

while($rs1= mysql_fetch_array($result)) {

 

if ($rs1['datap']>='10'){

if ($rs1['datap']<='900'){

$strXML .= "<entity id='" . $rs1['state'] . "' value='" . $rs1['datap'] . "'link='n-http://examplewebpage.php' />";

}

}

 

Thanks,

 

lhardee

 

 

 

Share this post


Link to post
Share on other sites

Hi Sumedh,

 

The code you attached displays markers. However, what I am trying to do is show markers conditionally. Is this possible?

 

For example:

 

 

$strQuery = "select state, sum(datap) as datap from (select tracker.state, tracker.data datap from tracker union all select cable_intrusion.state, cable_intrusion.data datap from cable_intrusion union all select fibertesting.state, fibertesting.data datap from fibertesting) as datap group by state";

 

$result = mysql_query($strQuery) or die(mysql_error());

# Check if we've records to show

if ($result) {

# Iterate through each record

while($rs1= mysql_fetch_array($result)) {

 

if ($rs1['datap']>='10'){

if ($rs1['datap']<='900'){

 

$strXML .="<markers>";

$strXML .="<definition>";

$strXML .= "<marker id='1' x='709.31' y='69.94' label='jump kit' labelPos='top' />";

$strXML .="</definition>";

$strXML .="<shapes>";

$strXML .= "<shape id='myCustomShape' type='image' url='base.png' labelPadding='12' />";

$strXML .="</shapes>";

$strXML .="<application>";

$strXML .= "<marker id='1' shapeId='myCustomShape' link='n-http%3a%2f%2examplewebpage'/>";

$strXML .="</application>";

$strXML .="</markers>";

$strXML .= "<styles>";

$strXML .= "<definition>";

$strXML .= "<stylename='markerAnim' type='animation' param='_y' start='0' duration='1.2' easing='bounce' />";

$strXML .= "</definition>";

$strXML .= "<application>";

$strXML .= "<applytoObject='MARKERS' styles='markerAnim' />";

$strXML .= "</application>";

$strXML .= "</styles>";

 

}

}

 

Thanks !!!

 

lhardee

 

 

Share this post


Link to post
Share on other sites
Guest Sumedh

Hi. smile.gif

 

To apply markers dynamically, you would need to specify the condition in the php code accordingly.( as per your requirement).

 

Above mentioned php code will work for your requirement.

 

Hope you have a great day. smile.gif

 

Happy FusionCharting ! biggrin.gif

Share this post


Link to post
Share on other sites

Sumedh,

 

Thanks for your assistance. However, I am having a difficult time calling markers upon a condition. Can anyone assist me with the following code below?

 

I am trying to make a marker appear if $rs1['datap'] value is between 10 & 900.

 

 

 

 

$strQuery = "select state, sum(datap) as datap from (select tracker.state, tracker.data datap from tracker union all select cable_intrusion.state, cable_intrusion.data datap from cable_intrusion union all select fibertesting.state, fibertesting.data datap from fibertesting) as datap group by state";

 

$result = mysql_query($strQuery) or die(mysql_error());

# Check if we've records to show

if ($result) {

# Iterate through each record

while($rs1= mysql_fetch_array($result)) {

 

if ($rs1['datap']>='10'){

if ($rs1['datap']<='900'){

 

***call marker***

 

 

 

 

Thanks

 

lhardee

Share this post


Link to post
Share on other sites
Guest Sumedh

Hi,smile.gif

 

Try to add following code before the while loop statement (in the above stated code.)

 

$strXML = "<map showCanvasBorder='0' borderColor='FFFFFF' connectorColor='000000' fillAlpha='80' hoverColor='FFFFFF' showBevel='0' numberSuffix='%25 of total US population' legendBorderColor='F1f1f1' hoverColor='FFFFFF' legendPosition='bottom'>";

....

$strXML .="</map>"; ( you would need to add this statement, after the closing the database connection.)

 

As you would need to specify the proper XML format for the map. Otherwise, map will not be rendered.

 

XML should start with <map> and end with </map> tags.

 

Please refer the following link for your reference:

http://docs.fusionch...HPDB_USMap.html

 

Hope this helps. smile.gif

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this