<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Placing a point using database values in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/placing-a-point-using-database-values/m-p/1012488#M71208</link>
    <description>&lt;P&gt;How do I place a marker at a location based on the results of a MYSQL database query?&lt;BR /&gt;&lt;BR /&gt;I'm able to display the values of&amp;nbsp; &amp;lt;?= $rLongitude ?&amp;gt;&amp;nbsp;&amp;nbsp;and&amp;nbsp;&amp;nbsp;&amp;lt;?= $rLatitude ?&amp;gt; as text on the parent webpage using php but how do I use these values within the javascript code to place a point/marker on the map at this location?&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;i.e. I know I need to change the following line of code....&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;var point = {&lt;BR /&gt;type: \"point\",&lt;BR /&gt;longitude: '19.874268',&lt;BR /&gt;latitude: '39.576056'&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;with something like...&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;var point = {&lt;BR /&gt;type: \"point\",&lt;BR /&gt;longitude: '&lt;STRONG&gt;$rLongitude&lt;/STRONG&gt;',&lt;BR /&gt;latitude: '&lt;STRONG&gt;$rLatitude&lt;/STRONG&gt;'&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;but this doesn't work! Help&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;Here's my code.&lt;BR /&gt;&lt;BR /&gt;&amp;lt;html lang="en"&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta charset="utf-8"&amp;gt;&lt;BR /&gt;&amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;&lt;BR /&gt;&amp;lt;meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width"&amp;gt;&lt;BR /&gt;&amp;lt;meta name="mobile-web-app-capable" content="yes"&amp;gt;&lt;BR /&gt;&amp;lt;meta name="apple-mobile-web-app-capable" content="yes"&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="./resources/ol.css"&amp;gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="./resources/ol3-layerswitcher.css"&amp;gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="./resources/qgis2web.css"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;!-- THIS SCRIPT DEFINES THE SIZE OF THE MAP --&amp;gt;&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;BR /&gt;html, body, #viewDiv {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;width: 100%;&lt;BR /&gt;height: 300px;&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/style&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;link rel="stylesheet" href="&lt;A href="https://js.arcgis.com/4.18/esri/themes/light/main.css" target="_blank"&gt;https://js.arcgis.com/4.18/esri/themes/light/main.css&lt;/A&gt;"&amp;gt;&lt;BR /&gt;&amp;lt;script src="&lt;A href="https://community.esri.com/" target="_blank"&gt;https://js.arcgis.com/4.18/"&amp;gt;&amp;lt;/script&lt;/A&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;?php&lt;BR /&gt;echo "&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;require([&lt;BR /&gt;\"esri/Map\",&lt;BR /&gt;\"esri/views/MapView\",&lt;BR /&gt;\"esri/Graphic\",&lt;BR /&gt;\"esri/layers/GraphicsLayer\",&lt;BR /&gt;\"esri/widgets/BasemapToggle\",&lt;BR /&gt;\"esri/widgets/BasemapGallery\",&lt;BR /&gt;\"dojo/domReady!\"&lt;BR /&gt;], function(Map, MapView, Graphic, GraphicsLayer, BasemapToggle, BasemapGallery) {&lt;/P&gt;&lt;P&gt;var map = new Map({&lt;BR /&gt;basemap: \"satellite\"&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;var view = new MapView({&lt;BR /&gt;container: \"viewDiv\",&lt;BR /&gt;map: map,&lt;BR /&gt;center: [19.874268,39.576056], // longitude, latitude&lt;BR /&gt;zoom: 16&lt;BR /&gt;});";&lt;BR /&gt;&lt;BR /&gt;$query = "SELECT rLongitude, rLatitude FROM cbcrecords WHERE rId = 36";&lt;/P&gt;&lt;P&gt;echo "&lt;BR /&gt;var basemapToggle = new BasemapToggle({&lt;BR /&gt;view: view,&lt;BR /&gt;nextBasemap: \"topo-vector\"&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;view.ui.add(basemapToggle, \"bottom-left\");&lt;/P&gt;&lt;P&gt;var graphicsLayer = new GraphicsLayer();&lt;BR /&gt;map.add(graphicsLayer);&lt;/P&gt;&lt;P&gt;var point = {&lt;BR /&gt;type: \"point\",&lt;BR /&gt;longitude: '&lt;STRONG&gt;19.874268&lt;/STRONG&gt;',&lt;BR /&gt;latitude: '&lt;STRONG&gt;39.576056&lt;/STRONG&gt;'&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var simpleMarkerSymbol = {&lt;BR /&gt;type: \"simple-marker\",&lt;BR /&gt;color: [226, 119, 40],&lt;BR /&gt;outline: {&lt;BR /&gt;color: [255, 255, 255],&lt;BR /&gt;width: 2&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var pointGraphic = new Graphic({&lt;BR /&gt;geometry: point,&lt;BR /&gt;symbol: simpleMarkerSymbol&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;graphicsLayer.add(pointGraphic);&lt;/P&gt;&lt;P&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;";&lt;BR /&gt;?&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Dec 2020 17:29:18 GMT</pubDate>
    <dc:creator>SteveCheshire</dc:creator>
    <dc:date>2020-12-28T17:29:18Z</dc:date>
    <item>
      <title>Placing a point using database values</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/placing-a-point-using-database-values/m-p/1012488#M71208</link>
      <description>&lt;P&gt;How do I place a marker at a location based on the results of a MYSQL database query?&lt;BR /&gt;&lt;BR /&gt;I'm able to display the values of&amp;nbsp; &amp;lt;?= $rLongitude ?&amp;gt;&amp;nbsp;&amp;nbsp;and&amp;nbsp;&amp;nbsp;&amp;lt;?= $rLatitude ?&amp;gt; as text on the parent webpage using php but how do I use these values within the javascript code to place a point/marker on the map at this location?&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;i.e. I know I need to change the following line of code....&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;var point = {&lt;BR /&gt;type: \"point\",&lt;BR /&gt;longitude: '19.874268',&lt;BR /&gt;latitude: '39.576056'&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;with something like...&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;var point = {&lt;BR /&gt;type: \"point\",&lt;BR /&gt;longitude: '&lt;STRONG&gt;$rLongitude&lt;/STRONG&gt;',&lt;BR /&gt;latitude: '&lt;STRONG&gt;$rLatitude&lt;/STRONG&gt;'&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;but this doesn't work! Help&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;Here's my code.&lt;BR /&gt;&lt;BR /&gt;&amp;lt;html lang="en"&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta charset="utf-8"&amp;gt;&lt;BR /&gt;&amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;&lt;BR /&gt;&amp;lt;meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width"&amp;gt;&lt;BR /&gt;&amp;lt;meta name="mobile-web-app-capable" content="yes"&amp;gt;&lt;BR /&gt;&amp;lt;meta name="apple-mobile-web-app-capable" content="yes"&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="./resources/ol.css"&amp;gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="./resources/ol3-layerswitcher.css"&amp;gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="./resources/qgis2web.css"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;!-- THIS SCRIPT DEFINES THE SIZE OF THE MAP --&amp;gt;&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;BR /&gt;html, body, #viewDiv {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;width: 100%;&lt;BR /&gt;height: 300px;&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/style&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;link rel="stylesheet" href="&lt;A href="https://js.arcgis.com/4.18/esri/themes/light/main.css" target="_blank"&gt;https://js.arcgis.com/4.18/esri/themes/light/main.css&lt;/A&gt;"&amp;gt;&lt;BR /&gt;&amp;lt;script src="&lt;A href="https://community.esri.com/" target="_blank"&gt;https://js.arcgis.com/4.18/"&amp;gt;&amp;lt;/script&lt;/A&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;?php&lt;BR /&gt;echo "&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;require([&lt;BR /&gt;\"esri/Map\",&lt;BR /&gt;\"esri/views/MapView\",&lt;BR /&gt;\"esri/Graphic\",&lt;BR /&gt;\"esri/layers/GraphicsLayer\",&lt;BR /&gt;\"esri/widgets/BasemapToggle\",&lt;BR /&gt;\"esri/widgets/BasemapGallery\",&lt;BR /&gt;\"dojo/domReady!\"&lt;BR /&gt;], function(Map, MapView, Graphic, GraphicsLayer, BasemapToggle, BasemapGallery) {&lt;/P&gt;&lt;P&gt;var map = new Map({&lt;BR /&gt;basemap: \"satellite\"&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;var view = new MapView({&lt;BR /&gt;container: \"viewDiv\",&lt;BR /&gt;map: map,&lt;BR /&gt;center: [19.874268,39.576056], // longitude, latitude&lt;BR /&gt;zoom: 16&lt;BR /&gt;});";&lt;BR /&gt;&lt;BR /&gt;$query = "SELECT rLongitude, rLatitude FROM cbcrecords WHERE rId = 36";&lt;/P&gt;&lt;P&gt;echo "&lt;BR /&gt;var basemapToggle = new BasemapToggle({&lt;BR /&gt;view: view,&lt;BR /&gt;nextBasemap: \"topo-vector\"&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;view.ui.add(basemapToggle, \"bottom-left\");&lt;/P&gt;&lt;P&gt;var graphicsLayer = new GraphicsLayer();&lt;BR /&gt;map.add(graphicsLayer);&lt;/P&gt;&lt;P&gt;var point = {&lt;BR /&gt;type: \"point\",&lt;BR /&gt;longitude: '&lt;STRONG&gt;19.874268&lt;/STRONG&gt;',&lt;BR /&gt;latitude: '&lt;STRONG&gt;39.576056&lt;/STRONG&gt;'&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var simpleMarkerSymbol = {&lt;BR /&gt;type: \"simple-marker\",&lt;BR /&gt;color: [226, 119, 40],&lt;BR /&gt;outline: {&lt;BR /&gt;color: [255, 255, 255],&lt;BR /&gt;width: 2&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var pointGraphic = new Graphic({&lt;BR /&gt;geometry: point,&lt;BR /&gt;symbol: simpleMarkerSymbol&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;graphicsLayer.add(pointGraphic);&lt;/P&gt;&lt;P&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;";&lt;BR /&gt;?&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 17:29:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/placing-a-point-using-database-values/m-p/1012488#M71208</guid>
      <dc:creator>SteveCheshire</dc:creator>
      <dc:date>2020-12-28T17:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Placing a point using database values</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/placing-a-point-using-database-values/m-p/1012496#M71211</link>
      <description>&lt;P&gt;I was able to get your code working with some slight alterations to remove extra syntax.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
&amp;lt;meta charset="utf-8"&amp;gt;
&amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&amp;gt;
&amp;lt;meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width"&amp;gt;
&amp;lt;meta name="mobile-web-app-capable" content="yes"&amp;gt;
&amp;lt;meta name="apple-mobile-web-app-capable" content="yes"&amp;gt;

&amp;lt;link rel="stylesheet" href="./resources/ol.css"&amp;gt;
&amp;lt;link rel="stylesheet" href="./resources/ol3-layerswitcher.css"&amp;gt;
&amp;lt;link rel="stylesheet" href="./resources/qgis2web.css"&amp;gt;

 

&amp;lt;!-- THIS SCRIPT DEFINES THE SIZE OF THE MAP --&amp;gt;
&amp;lt;style&amp;gt;
html, body, #viewDiv {
padding: 0;
margin: 0;
width: 100%;
height: 300px;
}
&amp;lt;/style&amp;gt;

 

&amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.18/esri/themes/light/main.css"&amp;gt;
&amp;lt;script src="https://js.arcgis.com/4.18/"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
require([
"esri/Map",
"esri/views/MapView",
"esri/Graphic",
"esri/layers/GraphicsLayer",
"esri/widgets/BasemapToggle",
"esri/widgets/BasemapGallery",
"dojo/domReady!"
], function(Map, MapView, Graphic, GraphicsLayer, BasemapToggle, BasemapGallery) {

  var map = new Map({
    basemap: "satellite"
  });

  var view = new MapView({
    container: "viewDiv",
    map: map,
    center: [19.874268,39.576056], // longitude, latitude
    zoom: 16
  });

  var basemapToggle = new BasemapToggle({
  view: view,
  nextBasemap: "topo-vector"
  });

  view.ui.add(basemapToggle, "bottom-left");

  var graphicsLayer = new GraphicsLayer();
  map.add(graphicsLayer);

  var point = {
    type: "point",
    longitude: '19.874268',
    latitude: '39.576056'
  };

  var simpleMarkerSymbol = {
    type: "simple-marker",
    color: [226, 119, 40],
    outline: {
      color: [255, 255, 255],
      width: 2
    }
  };

  var pointGraphic = new Graphic({
  geometry: point,
  symbol: simpleMarkerSymbol
  });

  graphicsLayer.add(pointGraphic);

});
&amp;lt;/script&amp;gt;

&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 28 Dec 2020 17:55:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/placing-a-point-using-database-values/m-p/1012496#M71211</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2020-12-28T17:55:46Z</dc:date>
    </item>
  </channel>
</rss>

