Could someone help me with this error emitted when I want to pass the coordinates to display the map throws this error
Compiler Error Message: CS0103: The name 'latLng' does not exist in the current context
If I put the fixed coordinates, goes perfectly. But I can't when it's for each one of the map.
Actually the plugin you are trying to use doesn't seem to be working well with version 7.
I am using this one : AngularGoogleMap
It's working well. If you setup the coordinates manually don't forget to setup a zoom level or it's not saved properly.
With this kind of code:
@{
var lat = CurrentPage.Map.Latitude;
var lng = CurrentPage.Map.Longitude;
var zoom = CurrentPage.Map.Zoom;
}
Hello MrFlo:
I'm using the "Google Maps Property Editor w / Google Places Autocomplete lookup" package and says it has compatibility with version 7.2 of Umbraco.
The map I can see but with fixed coordinates, the problem is when I try to pass the coordinates of each umbraco CONTENT'maps .
When I try to define the variable as null
GMapsLocation latLng = null;
It gives me the following error: CS0037 Can not convert null to 'GMapsLocation' because it is a value type that does not accept null values
Hi Dirk:
Sorry I did not reply earlier. I could solved this, initialize the variable var direcc = Model.Content.GetPropertyValue("direccion");, I don't know if it's the best way but I could fix it.
Thank you and MrFlo for your help.
After this mistake I had, I had a problem with coordinates, showed me the comma instead of a point. And it solved this way
Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
GMapsValueConverter.cs
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
using System.Threading;
public class GMapsValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
{
return "Netaddicts.GMaps".Equals(propertyType.PropertyEditorAlias);
}
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
if (source == null || string.IsNullOrWhiteSpace(source.ToString()))
{
return null;
}
var coordinates = source.ToString().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
//string[] coordinates = source.ToString().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
return new GMapsLocation
{
Latitude = decimal.Parse(coordinates[0], CultureInfo.InvariantCulture),
Longitude = decimal.Parse(coordinates[1], CultureInfo.InvariantCulture)
};
}
}
Google Maps Coordinates error
Could someone help me with this error emitted when I want to pass the coordinates to display the map throws this error Compiler Error Message: CS0103: The name 'latLng' does not exist in the current context
If I put the fixed coordinates, goes perfectly. But I can't when it's for each one of the map.
Hi Ariel,
You could just add a check for not null value or in your foreach ?
Hi Florent
Thanks for replying Could you give me an example please. This control will allow me to pass the value to var mapOptions and see the map?
Thanks
Hi Ariel,
Actually the plugin you are trying to use doesn't seem to be working well with version 7. I am using this one : AngularGoogleMap It's working well. If you setup the coordinates manually don't forget to setup a zoom level or it's not saved properly.
With this kind of code:
Hello MrFlo: I'm using the "Google Maps Property Editor w / Google Places Autocomplete lookup" package and says it has compatibility with version 7.2 of Umbraco. The map I can see but with fixed coordinates, the problem is when I try to pass the coordinates of each umbraco CONTENT'maps .
Thanks again
you're defining and assigning latLng variable in foreach, whereas you try to use that var outside of the foreach (therefore generating an error)
Move definition of latLng just below Layout statement
@{ Layout = "Master.cshtml"; GMapsLocation latLng = null; }
and remove var from
@{ foreach(...) { var latLng = ... } }
and you won't get that error anymore.
Cheers, Dirk
Dirk:
When I try to define the variable as null GMapsLocation latLng = null; It gives me the following error: CS0037 Can not convert null to 'GMapsLocation' because it is a value type that does not accept null values
Cheers, Ariel
Hi Dirk: Sorry I did not reply earlier. I could solved this, initialize the variable var direcc = Model.Content.GetPropertyValue("direccion");, I don't know if it's the best way but I could fix it. Thank you and MrFlo for your help.
After this mistake I had, I had a problem with coordinates, showed me the comma instead of a point. And it solved this way Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
I haven't see that one. @Dirk Well spoted!
is working on a reply...