html - adding strings in javascript -


i working on creating page using html , javascript. have json file proves inputs of contents need. im trying have address variable setup google map api can displayed on page.

<html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>google maps javascript api v3 example: geocoding simple</title> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript">   var geocoder;   var map;   var address = cmpyjson[jobcmpyid].company_name+" company, "+locjson[joblocid].location_name;   function initialize() {     geocoder = new google.maps.geocoder();     var latlng = new google.maps.latlng(-34.397, 150.644);     var myoptions = {       zoom: 11,       center: latlng,     maptypecontrol: true,     maptypecontroloptions: {style: google.maps.maptypecontrolstyle.dropdown_menu},     navigationcontrol: true,       maptypeid: google.maps.maptypeid.roadmap     };     map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions);     if (geocoder) {       geocoder.geocode( { 'address': address}, function(results, status) {         if (status == google.maps.geocoderstatus.ok) {           if (status != google.maps.geocoderstatus.zero_results) {           map.setcenter(results[0].geometry.location);              var infowindow = new google.maps.infowindow(                 { content: '<b>'+address+'</b>',                   size: new google.maps.size(150,50)                 });              var marker = new google.maps.marker({                 position: results[0].geometry.location,                 map: map,                  title:address             });              google.maps.event.addlistener(marker, 'click', function() {                 infowindow.open(map,marker);             });            } else {             alert("no results found");           }         } else {           alert("geocode not successful following reason: " + status);         }       });     }   } </script> </head> <body style="margin:0px; padding:0px;" onload="initialize()">  <div id="map_canvas" style="width:100%; height:200px;"></div> </body> </html> 

above part of code. address variable has

var address= "google company, austin, tx" 

for google recognize properly. if know fact json returns im asking, problem here? how go fixing it?

updated ease confusions.

when view source code on website, see returned values strings...

<head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>google maps javascript api v3 example: geocoding simple</title> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript">   var geocoder;   var map;   var address =oracle+" company, "+san francisco, ca;   function initialize() {     geocoder = new google.maps.geocoder();     var latlng = new google.maps.latlng(-34.397, 150.644);     var myoptions = {       zoom: 11,       center: latlng,     maptypecontrol: true,     maptypecontroloptions: {style: google.maps.maptypecontrolstyle.dropdown_menu},     navigationcontrol: true,       maptypeid: google.maps.maptypeid.roadmap     };     map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions);     if (geocoder) {       geocoder.geocode( { 'address': address}, function(results, status) {         if (status == google.maps.geocoderstatus.ok) {           if (status != google.maps.geocoderstatus.zero_results) {           map.setcenter(results[0].geometry.location);              var infowindow = new google.maps.infowindow(                 { content: '<b>'+address+'</b>',                   size: new google.maps.size(150,50)                 });              var marker = new google.maps.marker({                 position: results[0].geometry.location,                 map: map,                  title:address             });              google.maps.event.addlistener(marker, 'click', function() {                 infowindow.open(map,marker);             });            } else {             alert("no results found");           }         } else {           alert("geocode not successful following reason: " + status);         }       });     }   } </script> </head> <body style="margin:0px; padding:0px;" onload="initialize()">  <div id="map_canvas" style="width:100%; height:200px;"></div> </body> 

assuming of these variables exist, following line should be:

var address = cmpyjson[jobcmpyid].company_name+" company, "+locjson[joblocid].location_name; 

i removed of curly brackets make syntactically correct.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -