I put yandex map (russian analogue of google map) on my view. But but baloon's location does not match the coordinates!
Here is the code:
Example #1 - baloons display not correct
<script type="text/javascript">
ymaps.ready(init);
var myMap,
myPlacemark;
function init() {
myMap = new ymaps.Map("map", {
center: [55.76, 37.64],
zoom: 10
});
@foreach (var person in Model)
{
<text>
console.log('Service = @person.ServiceName, x = @person.CoordinateX, y = @person.CoordinateY');
myPlacemark = new ymaps.Placemark([@(person.CoordinateX), @(person.CoordinateY)], {
hintContent: '@(person.ServiceName)',
balloonContent: '@(person.CoordinateX), @(person.CoordinateY)'
});
myMap.geoObjects.add(myPlacemark);
</text>
}
}
</script>
But if I change it to constants (not in loop "foreach"), everything is normal:
Example #2 - baloons display correct
<script type="text/javascript">
ymaps.ready(init);
var myMap,
myPlacemark;
function init() {
myMap = new ymaps.Map("map", {
center: [55.76, 37.64],
zoom: 10
});
myPlacemark = new ymaps.Placemark([55.871030, 37.658510], {
hintContent: 'hint',
balloonContent: 'content'
});
myMap.geoObjects.add(myPlacemark);
myPlacemark = new ymaps.Placemark([55.782392, 37.614924], {
hintContent: 'hint',
balloonContent: 'content'
});
myMap.geoObjects.add(myPlacemark);
}
</script>
NOTE: in Example #1 in console I get rigth values:
Service = something1, x = 55,87103, y = 37,65851
Service = something2, x = 55,782392, y = 37,614924
but baloon's location does not match the coordinates:
We've found out that the problem was in the way ASP.Net outputs the numbers in the posted code snippets. They're printed into JS code with floating commas instead of points.