Michael Hunger
unread,Aug 21, 2012, 7:21:18 PM8/21/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ne...@googlegroups.com
I'm vary about setting javascript variables by php echo :)
Wouldn't it make more sense to retrieve them from the server via a ajax request in javascript?
I think it is just a quoting/escaping problem. I assume it works when you use static values there.
Michael
Am 21.08.2012 um 21:34 schrieb Shad King:
> I am somewhat new to the NEO4J community and have been assigned a task of implementing Google Maps within our project. As of right now I have been able to create the map and populate it using the standard markers. Basically what I want to do is take the Nodes that we have created and display them on the map ( which I have done). Then I want to draw lines between them similar to what Google Maps offers as flight paths. and last I want to be able to take the node icon that the user uploaded to the database and display that as the marker.
>
> Where I am running into the problem is that when I declare my image as var image = "<?php echo $entity_icon?>"; then my map breaks. I am doing it the same way that I did when I called the address from the database and that works.
>
> Below is the complete Java script
>
> <script type="text/javascript">
>
> var infowindow = new google.maps.InfoWindow();
> var browserSupportFlag = new Boolean();
>
>
>
> function initialize()
> {
> var latlng = new google.maps.LatLng(38.9550040,-77.4045560);
> var settings =
>
>
> //sets the settings of the map
>
> {
> zoom: 5,
> center: latlng,
> mapTypeControl: true,
> mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
> navigationControl: true,
> mapTypeId: google.maps.MapTypeId.ROADMAP
> }
>
> geocoder = new google.maps.Geocoder();
> map = new google.maps.Map(document.getElementById("map_canvas"), settings);
>
> // Try W3C Geolocation (Preferred)
>
> if(navigator.geolocation)
> {
> browserSupportFlag = true;
> navigator.geolocation.getCurrentPosition(function(position)
>
> {
> initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
> map.setCenter(initialLocation);
> }, function()
>
> {
> handleNoGeolocation(browserSupportFlag);
> });
> }
>
> // Browser doesn't support Geolocation
>
> else
> {
> browserSupportFlag = false;
> handleNoGeolocation(browserSupportFlag);
> }
>
>
>
> function handleNoGeolocation(errorFlag)
> {
> if (errorFlag == true)
>
> {
> alert("Geolocation service failed.");
> initialLocation = Virgina;
> }
> else
> {
> alert("Your browser doesn't support geolocation. We've placed you in here.");
> initialLocation = '';
> }
> map.setCenter(initialLocation);
> }
> }
>
>
>
> // Takes an address and places a marker in google maps
>
> function codeAddress()
>
> {
> var address = "<?php echo $node_address?>";
> var description = "<?php echo $node_title?>";
> var properties = "<?php echo $default_properties?>"
> <?php
> $js_array = json_encode($end_node_addresses);
> echo "var end_addresses = ". $js_array . ";\n";
> ?>
>
>
> var image = "<?php echo $entity_icon?>";
>
> geocoder.geocode( { 'address': address}, function(results, status)
> {
> if (status == google.maps.GeocoderStatus.OK)
> {
> map.setCenter(results[0].geometry.location);
>
> var contentString = '<div id="contentmarker">'+
> '<div id="siteNotice">'+
> '</div>'+
> '<h2 id="firstHeading" class="firstHeading"><?php echo $node_title?></h2>'+
> '<div id="bodyContent">'+
> '<p> Is located in <b><?php echo $node_address?><?php echo $default_properties?></b> <b></b></p>'+
> '</div>'+
> '</div>';
>
> var infowindow = new google.maps.InfoWindow(
> {
> content: contentString
> });
>
>
> var marker = new google.maps.Marker({
> map: map,
> position: results[0].geometry.location,
> icon: image,
> title: address
> });
>
> google.maps.event.addListener(marker, 'click', function() {
> infowindow.open(map,marker);
> });
> }
>
> else
> {
> alert("Geocode was not successful for the following reason: " + status);
> }
> });
>
> var title_vars = end_addresses;
>
> for (i = 0; i < end_addresses.length; i++)
> {
> geocoder.geocode( { 'address': end_addresses[i]}, function(results, status)
> {
> if (status == google.maps.GeocoderStatus.OK)
> {
> map.setCenter(results[0].geometry.location);
>
> var contentString = '<div id="contentmarker">'+
> '<div id="siteNotice">'+
> '</div>'+
> '<h2 id="firstHeading" class="firstHeading"><?php echo $node_title?></h2>'+
> '<div id="bodyContent">'+
> '<p> Is located in <?php echo end_addresses?></p>'+
> '</div>'+
> '</div>';
>
> var infowindow = new google.maps.InfoWindow({
> content: contentString
> });
>
> var marker = new google.maps.Marker({
> map: map,
> position: results[0].geometry.location,
> title: title_vars.shift(),
> });
> google.maps.event.addListener(marker, 'click', function() {
> infowindow.open(map,marker);
> });
> }
>
> else
> {
> alert("Geocode was not successful for the following reason: " + status);
> }
> });
> }
> }
> </script>
>
> --
>
>